@@ -31,9 +31,9 @@ import java.util.Map; | |||
import java.util.Set; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.resources.Scopes; | |||
import org.sonar.api.ce.ComputeEngineSide; | |||
import org.sonar.api.server.ServerSide; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.web.UserRole; | |||
@@ -112,7 +112,7 @@ public class ComponentService { | |||
try { | |||
ComponentDto projectOrModule = getByKey(session, projectOrModuleKey); | |||
userSession.checkComponentUuidPermission(UserRole.ADMIN, projectOrModule.projectUuid()); | |||
dbClient.resourceKeyUpdaterDao().updateKey(projectOrModule.getId(), newKey); | |||
dbClient.resourceKeyUpdaterDao().updateKey(projectOrModule.uuid(), newKey); | |||
session.commit(); | |||
session.commit(); | |||
@@ -126,7 +126,7 @@ public class ComponentService { | |||
try { | |||
ComponentDto project = getByKey(projectKey); | |||
userSession.checkComponentUuidPermission(UserRole.ADMIN, project.projectUuid()); | |||
return dbClient.resourceKeyUpdaterDao().checkModuleKeysBeforeRenaming(project.getId(), stringToReplace, replacementString); | |||
return dbClient.resourceKeyUpdaterDao().checkModuleKeysBeforeRenaming(project.uuid(), stringToReplace, replacementString); | |||
} finally { | |||
session.close(); | |||
} | |||
@@ -138,7 +138,7 @@ public class ComponentService { | |||
try { | |||
ComponentDto project = getByKey(session, projectKey); | |||
userSession.checkComponentUuidPermission(UserRole.ADMIN, project.projectUuid()); | |||
dbClient.resourceKeyUpdaterDao().bulkUpdateKey(session, project.getId(), stringToReplace, replacementString); | |||
dbClient.resourceKeyUpdaterDao().bulkUpdateKey(session, project.uuid(), stringToReplace, replacementString); | |||
session.commit(); | |||
} finally { | |||
session.close(); | |||
@@ -185,6 +185,7 @@ public class ComponentService { | |||
String uuid = Uuids.create(); | |||
ComponentDto component = new ComponentDto() | |||
.setUuid(uuid) | |||
.setRootUuid(uuid) | |||
.setModuleUuid(null) | |||
.setModuleUuidPath(ComponentDto.MODULE_UUID_PATH_SEP + uuid + ComponentDto.MODULE_UUID_PATH_SEP) | |||
.setProjectUuid(uuid) |
@@ -134,11 +134,11 @@ public class AppAction implements RequestHandler { | |||
json.prop("longName", component.longName()); | |||
json.prop("q", component.qualifier()); | |||
ComponentDto parentProject = nullableComponentById(component.parentProjectId(), session); | |||
ComponentDto parentProject = retrieveRootIfNotCurrentComponent(component, session); | |||
ComponentDto project = dbClient.componentDao().selectOrFailByUuid(session, component.projectUuid()); | |||
// Do not display parent project if parent project and project are the same | |||
boolean displayParentProject = parentProject != null && !parentProject.getId().equals(project.getId()); | |||
boolean displayParentProject = parentProject != null && !parentProject.uuid().equals(project.uuid()); | |||
json.prop("subProject", displayParentProject ? parentProject.key() : null); | |||
json.prop("subProjectName", displayParentProject ? parentProject.longName() : null); | |||
json.prop("project", project.key()); | |||
@@ -188,11 +188,11 @@ public class AppAction implements RequestHandler { | |||
} | |||
@CheckForNull | |||
private ComponentDto nullableComponentById(@Nullable Long componentId, DbSession session) { | |||
if (componentId != null) { | |||
return dbClient.componentDao().selectOrFailById(session, componentId); | |||
private ComponentDto retrieveRootIfNotCurrentComponent(ComponentDto componentDto, DbSession session) { | |||
if (componentDto.uuid().equals(componentDto.getRootUuid())) { | |||
return null; | |||
} | |||
return null; | |||
return dbClient.componentDao().selectOrFailByUuid(session, componentDto.getRootUuid()); | |||
} | |||
@CheckForNull |
@@ -50,11 +50,11 @@ class ComponentDtoToWsComponent { | |||
return wsComponent; | |||
} | |||
static WsComponents.Component.Builder componentDtoToWsComponent(ComponentDto component, Map<Long, ComponentDto> referenceComponentsById) { | |||
static WsComponents.Component.Builder componentDtoToWsComponent(ComponentDto component, Map<String, ComponentDto> referenceComponentsByUuid) { | |||
WsComponents.Component.Builder wsComponent = componentDtoToWsComponent(component); | |||
ComponentDto referenceComponent = referenceComponentsById.get(component.getCopyResourceId()); | |||
if (!referenceComponentsById.isEmpty() && referenceComponent != null) { | |||
ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid()); | |||
if (referenceComponent != null) { | |||
wsComponent.setRefId(referenceComponent.uuid()); | |||
wsComponent.setRefKey(referenceComponent.key()); | |||
} |
@@ -19,18 +19,15 @@ | |||
*/ | |||
package org.sonar.server.component.ws; | |||
import com.google.common.base.Function; | |||
import com.google.common.base.Predicates; | |||
import com.google.common.collect.ImmutableSortedSet; | |||
import com.google.common.collect.Sets; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nonnull; | |||
import org.sonar.api.i18n.I18n; | |||
import org.sonar.api.resources.ResourceTypes; | |||
import org.sonar.api.server.ws.Request; | |||
@@ -179,31 +176,26 @@ public class TreeAction implements ComponentsWsAction { | |||
default: | |||
throw new IllegalStateException("Unknown component tree strategy"); | |||
} | |||
Map<Long, ComponentDto> referenceComponentUuidsById = searchReferenceComponentUuidsById(dbSession, components); | |||
Map<String, ComponentDto> referenceComponentsByUuid = searchreferenceComponentsByUuid(dbSession, components); | |||
return buildResponse(baseComponent, components, referenceComponentUuidsById, | |||
return buildResponse(baseComponent, components, referenceComponentsByUuid, | |||
Paging.forPageIndex(query.getPage()).withPageSize(query.getPageSize()).andTotal(total)); | |||
} finally { | |||
dbClient.closeSession(dbSession); | |||
} | |||
} | |||
private Map<Long, ComponentDto> searchReferenceComponentUuidsById(DbSession dbSession, List<ComponentDtoWithSnapshotId> components) { | |||
List<Long> referenceComponentIds = from(components) | |||
.transform(ComponentDtoWithSnapshotIdToCopyResourceIdFunction.INSTANCE) | |||
.filter(Predicates.<Long>notNull()) | |||
private Map<String, ComponentDto> searchreferenceComponentsByUuid(DbSession dbSession, List<ComponentDtoWithSnapshotId> components) { | |||
List<String> referenceComponentIds = from(components) | |||
.transform(ComponentDto::getCopyResourceUuid) | |||
.filter(Predicates.<String>notNull()) | |||
.toList(); | |||
if (referenceComponentIds.isEmpty()) { | |||
return emptyMap(); | |||
} | |||
List<ComponentDto> referenceComponents = dbClient.componentDao().selectByIds(dbSession, referenceComponentIds); | |||
Map<Long, ComponentDto> referenceComponentUuidsById = new HashMap<>(); | |||
for (ComponentDto referenceComponent : referenceComponents) { | |||
referenceComponentUuidsById.put(referenceComponent.getId(), referenceComponent); | |||
} | |||
return referenceComponentUuidsById; | |||
return from(dbClient.componentDao().selectByUuids(dbSession, referenceComponentIds)) | |||
.uniqueIndex(ComponentDto::uuid); | |||
} | |||
private void checkPermissions(ComponentDto baseComponent) { | |||
@@ -215,8 +207,8 @@ public class TreeAction implements ComponentsWsAction { | |||
} | |||
} | |||
private static TreeWsResponse buildResponse(ComponentDto baseComponent, List<ComponentDtoWithSnapshotId> components, Map<Long, ComponentDto> referenceComponentsById, | |||
Paging paging) { | |||
private static TreeWsResponse buildResponse(ComponentDto baseComponent, List<ComponentDtoWithSnapshotId> components, | |||
Map<String, ComponentDto> referenceComponentsByUuid, Paging paging) { | |||
TreeWsResponse.Builder response = TreeWsResponse.newBuilder(); | |||
response.getPagingBuilder() | |||
.setPageIndex(paging.pageIndex()) | |||
@@ -224,9 +216,9 @@ public class TreeAction implements ComponentsWsAction { | |||
.setTotal(paging.total()) | |||
.build(); | |||
response.setBaseComponent(componentDtoToWsComponent(baseComponent, referenceComponentsById)); | |||
response.setBaseComponent(componentDtoToWsComponent(baseComponent, referenceComponentsByUuid)); | |||
for (ComponentDto dto : components) { | |||
response.addComponents(componentDtoToWsComponent(dto, referenceComponentsById)); | |||
response.addComponents(componentDtoToWsComponent(dto, referenceComponentsByUuid)); | |||
} | |||
return response.build(); | |||
@@ -238,7 +230,7 @@ public class TreeAction implements ComponentsWsAction { | |||
.setTotal(0) | |||
.setPageIndex(request.getPage()) | |||
.setPageSize(request.getPageSize()); | |||
response.setBaseComponent(componentDtoToWsComponent(baseComponent, Collections.<Long, ComponentDto>emptyMap())); | |||
response.setBaseComponent(componentDtoToWsComponent(baseComponent, Collections.<String, ComponentDto>emptyMap())); | |||
return response.build(); | |||
} | |||
@@ -302,11 +294,4 @@ public class TreeAction implements ComponentsWsAction { | |||
return treeWsRequest; | |||
} | |||
private enum ComponentDtoWithSnapshotIdToCopyResourceIdFunction implements Function<ComponentDtoWithSnapshotId, Long> { | |||
INSTANCE; | |||
@Override | |||
public Long apply(@Nonnull ComponentDtoWithSnapshotId input) { | |||
return input.getCopyResourceId(); | |||
} | |||
} | |||
} |
@@ -25,18 +25,12 @@ import static java.util.Objects.requireNonNull; | |||
@Immutable | |||
public class ProjectViewAttributes { | |||
private final long projectId; | |||
private final String projectUuid; | |||
public ProjectViewAttributes(long projectId, String projectUuid) { | |||
this.projectId = projectId; | |||
public ProjectViewAttributes(String projectUuid) { | |||
this.projectUuid = requireNonNull(projectUuid, "projectUuid can't be null"); | |||
} | |||
public long getProjectId() { | |||
return projectId; | |||
} | |||
public String getProjectUuid() { | |||
return projectUuid; | |||
} | |||
@@ -44,7 +38,6 @@ public class ProjectViewAttributes { | |||
@Override | |||
public String toString() { | |||
return "ProjectViewAttributes{" + | |||
"projectId=" + projectId + | |||
", projectUuid='" + projectUuid + '\'' + | |||
'}'; | |||
} |
@@ -192,6 +192,7 @@ public class PersistComponentsStep implements ComputationStep { | |||
res.setLongName(res.name()); | |||
res.setDescription(project.getDescription()); | |||
res.setProjectUuid(res.uuid()); | |||
res.setRootUuid(res.uuid()); | |||
res.setModuleUuidPath(MODULE_UUID_PATH_SEP + res.uuid() + MODULE_UUID_PATH_SEP); | |||
return res; | |||
@@ -250,6 +251,7 @@ public class PersistComponentsStep implements ComputationStep { | |||
res.setDescription(view.getDescription()); | |||
res.setLongName(res.name()); | |||
res.setProjectUuid(res.uuid()); | |||
res.setRootUuid(res.uuid()); | |||
res.setModuleUuidPath(MODULE_UUID_PATH_SEP + res.uuid() + MODULE_UUID_PATH_SEP); | |||
return res; | |||
@@ -276,7 +278,7 @@ public class PersistComponentsStep implements ComputationStep { | |||
res.setQualifier(Qualifiers.PROJECT); | |||
res.setName(projectView.getName()); | |||
res.setLongName(res.name()); | |||
res.setCopyResourceId(projectView.getProjectViewAttributes().getProjectId()); | |||
res.setCopyComponentUuid(projectView.getProjectViewAttributes().getProjectUuid()); | |||
setRootAndParentModule(res, path); | |||
@@ -301,7 +303,7 @@ public class PersistComponentsStep implements ComputationStep { | |||
*/ | |||
private static void setRootAndParentModule(ComponentDto res, PathAwareVisitor.Path<ComponentDtoHolder> path) { | |||
ComponentDto projectDto = from(path.getCurrentPath()).last().get().getElement().getDto(); | |||
res.setParentProjectId(projectDto.getId()); | |||
res.setRootUuid(projectDto.uuid()); | |||
res.setProjectUuid(projectDto.uuid()); | |||
ComponentDto parentModule = path.parent().getDto(); | |||
@@ -318,7 +320,7 @@ public class PersistComponentsStep implements ComputationStep { | |||
.first() | |||
.get() | |||
.getElement().getDto(); | |||
componentDto.setParentProjectId(parentModule.getId()); | |||
componentDto.setRootUuid(parentModule.uuid()); | |||
componentDto.setProjectUuid(parentModule.projectUuid()); | |||
componentDto.setModuleUuid(parentModule.uuid()); | |||
componentDto.setModuleUuidPath(parentModule.moduleUuidPath()); | |||
@@ -350,12 +352,12 @@ public class PersistComponentsStep implements ComputationStep { | |||
existingComponent.setModuleUuidPath(newComponent.moduleUuidPath()); | |||
modified = true; | |||
} | |||
if (!ObjectUtils.equals(existingComponent.parentProjectId(), newComponent.parentProjectId())) { | |||
existingComponent.setParentProjectId(newComponent.parentProjectId()); | |||
if (!ObjectUtils.equals(existingComponent.getRootUuid(), newComponent.getRootUuid())) { | |||
existingComponent.setRootUuid(newComponent.getRootUuid()); | |||
modified = true; | |||
} | |||
if (!ObjectUtils.equals(existingComponent.getCopyResourceId(), newComponent.getCopyResourceId())) { | |||
existingComponent.setCopyResourceId(newComponent.getCopyResourceId()); | |||
if (!ObjectUtils.equals(existingComponent.getCopyResourceUuid(), newComponent.getCopyResourceUuid())) { | |||
existingComponent.setCopyComponentUuid(newComponent.getCopyResourceUuid()); | |||
modified = true; | |||
} | |||
if (!existingComponent.isEnabled()) { |
@@ -84,7 +84,7 @@ public class DuplicationsJsonWriter { | |||
private void writeFiles(Map<String, String> refByComponentKey, JsonWriter json, DbSession session) { | |||
Map<String, ComponentDto> projectsByUuid = newHashMap(); | |||
Map<Long, ComponentDto> parentProjectsById = newHashMap(); | |||
Map<String, ComponentDto> parentProjectsByUuid = newHashMap(); | |||
for (Map.Entry<String, String> entry : refByComponentKey.entrySet()) { | |||
String componentKey = entry.getKey(); | |||
String ref = entry.getValue(); | |||
@@ -95,7 +95,7 @@ public class DuplicationsJsonWriter { | |||
addFile(json, file); | |||
ComponentDto project = getProject(file.projectUuid(), projectsByUuid, session); | |||
ComponentDto parentProject = getParentProject(file.parentProjectId(), parentProjectsById, session); | |||
ComponentDto parentProject = getParentProject(file.getRootUuid(), parentProjectsByUuid, session); | |||
addProject(json, project, parentProject); | |||
json.endObject(); | |||
@@ -116,7 +116,7 @@ public class DuplicationsJsonWriter { | |||
json.prop("projectName", project.longName()); | |||
// Do not return sub project if sub project and project are the same | |||
boolean displaySubProject = subProject != null && !subProject.getId().equals(project.getId()); | |||
boolean displaySubProject = subProject != null && !subProject.uuid().equals(project.uuid()); | |||
if (displaySubProject) { | |||
json.prop("subProject", subProject.key()); | |||
json.prop("subProjectUuid", subProject.uuid()); | |||
@@ -137,13 +137,13 @@ public class DuplicationsJsonWriter { | |||
return project; | |||
} | |||
private ComponentDto getParentProject(@Nullable Long projectId, Map<Long, ComponentDto> subProjectsById, DbSession session) { | |||
ComponentDto project = subProjectsById.get(projectId); | |||
if (project == null && projectId != null) { | |||
Optional<ComponentDto> projectOptional = componentDao.selectById(session, projectId); | |||
private ComponentDto getParentProject(String rootUuid, Map<String, ComponentDto> subProjectsByUuid, DbSession session) { | |||
ComponentDto project = subProjectsByUuid.get(rootUuid); | |||
if (project == null) { | |||
Optional<ComponentDto> projectOptional = componentDao.selectByUuid(session, rootUuid); | |||
if (projectOptional.isPresent()) { | |||
project = projectOptional.get(); | |||
subProjectsById.put(project.getId(), project); | |||
subProjectsByUuid.put(project.uuid(), project); | |||
} | |||
} | |||
return project; |
@@ -69,9 +69,7 @@ import static com.google.common.collect.FluentIterable.from; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static java.lang.String.format; | |||
import static org.sonar.api.utils.DateUtils.longToDate; | |||
import static org.sonar.db.component.ComponentDtoFunctions.toCopyResourceId; | |||
import static org.sonar.db.component.ComponentDtoFunctions.toProjectUuid; | |||
import static org.sonar.db.component.ComponentDtoFunctions.toUuid; | |||
import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; | |||
import static org.sonar.server.ws.WsUtils.checkRequest; | |||
import static org.sonarqube.ws.client.issue.IssueFilterParameters.COMPONENTS; | |||
@@ -403,9 +401,7 @@ public class IssueQueryService { | |||
Collection<String> developerUuids = Collections2.transform(technicalProjects, toProjectUuid()); | |||
Collection<String> authorsFromProjects = authorsFromParamsOrFromDeveloper(session, developerUuids, authors); | |||
builder.authors(authorsFromProjects); | |||
Collection<Long> projectIds = Collections2.transform(technicalProjects, toCopyResourceId()); | |||
List<ComponentDto> originalProjects = dbClient.componentDao().selectByIds(session, projectIds); | |||
Collection<String> projectUuids = Collections2.transform(originalProjects, toUuid()); | |||
Collection<String> projectUuids = Collections2.transform(technicalProjects, ComponentDto::getCopyResourceUuid); | |||
builder.projectUuids(projectUuids); | |||
} | |||
@@ -92,7 +92,7 @@ public class IssueAuthorizationDao { | |||
" FROM projects " + | |||
" WHERE " + | |||
" projects.qualifier = 'TRK' " + | |||
" AND projects.copy_resource_id is NULL " + | |||
" AND projects.copy_component_uuid is NULL " + | |||
" {dateCondition} " + | |||
" UNION " + | |||
@@ -108,7 +108,7 @@ public class IssueAuthorizationDao { | |||
" INNER JOIN users ON users.id = user_roles.user_id " + | |||
" WHERE " + | |||
" projects.qualifier = 'TRK' " + | |||
" AND projects.copy_resource_id is NULL " + | |||
" AND projects.copy_component_uuid is NULL " + | |||
" {dateCondition} " + | |||
" UNION " + | |||
@@ -124,7 +124,7 @@ public class IssueAuthorizationDao { | |||
" INNER JOIN groups ON groups.id = group_roles.group_id " + | |||
" WHERE " + | |||
" projects.qualifier = 'TRK' " + | |||
" AND projects.copy_resource_id is NULL " + | |||
" AND projects.copy_component_uuid is NULL " + | |||
" {dateCondition} " + | |||
" AND group_id IS NOT NULL " + | |||
" UNION " + | |||
@@ -140,7 +140,7 @@ public class IssueAuthorizationDao { | |||
" INNER JOIN group_roles ON group_roles.resource_id = projects.id AND group_roles.role='user' " + | |||
" WHERE " + | |||
" projects.qualifier = 'TRK' " + | |||
" AND projects.copy_resource_id is NULL " + | |||
" AND projects.copy_component_uuid is NULL " + | |||
" {dateCondition} " + | |||
" AND group_roles.group_id IS NULL " + | |||
" ) project_authorization"; |
@@ -304,10 +304,11 @@ public class SearchResponseFormat { | |||
Collection<ComponentDto> components = data.getComponents(); | |||
if (components != null) { | |||
for (ComponentDto dto : components) { | |||
String uuid = dto.uuid(); | |||
Issues.Component.Builder builder = Issues.Component.newBuilder() | |||
.setId(dto.getId()) | |||
.setKey(dto.key()) | |||
.setUuid(dto.uuid()) | |||
.setUuid(uuid) | |||
.setQualifier(dto.qualifier()) | |||
.setName(nullToEmpty(dto.name())) | |||
.setLongName(nullToEmpty(dto.longName())) | |||
@@ -320,12 +321,11 @@ public class SearchResponseFormat { | |||
} | |||
// On a root project, parentProjectId is null but projectId is equal to itself, which make no sense. | |||
if (dto.projectUuid() != null && dto.parentProjectId() != null) { | |||
if (!uuid.equals(dto.getRootUuid())) { | |||
ComponentDto project = data.getComponentByUuid(dto.projectUuid()); | |||
builder.setProjectId(project.getId()); | |||
} | |||
if (dto.parentProjectId() != null) { | |||
builder.setSubProjectId(dto.parentProjectId()); | |||
ComponentDto subProject = data.getComponentByUuid(dto.getRootUuid()); | |||
builder.setSubProjectId(subProject.getId()); | |||
} | |||
result.add(builder.build()); | |||
} |
@@ -24,15 +24,15 @@ import org.apache.commons.lang.StringUtils; | |||
public class MeasureFilterRow { | |||
private final long snapshotId; | |||
private final long resourceId; | |||
private final long resourceRootId; | |||
private final String rootComponentUuid; | |||
private String sortText = null; | |||
private Long sortDate = null; | |||
private Double sortDouble = null; | |||
MeasureFilterRow(long snapshotId, long resourceId, long resourceRootId) { | |||
MeasureFilterRow(long snapshotId, long resourceId, String rootComponentUuid) { | |||
this.snapshotId = snapshotId; | |||
this.resourceId = resourceId; | |||
this.resourceRootId = resourceRootId; | |||
this.rootComponentUuid = rootComponentUuid; | |||
} | |||
public long getSnapshotId() { | |||
@@ -43,8 +43,8 @@ public class MeasureFilterRow { | |||
return resourceId; | |||
} | |||
public long getResourceRootId() { | |||
return resourceRootId; | |||
public String getRootComponentUuid() { | |||
return rootComponentUuid; | |||
} | |||
public String getSortText() { |
@@ -96,7 +96,7 @@ class MeasureFilterSql { | |||
private String generateSql() { | |||
StringBuilder sb = new StringBuilder(1000); | |||
sb.append("SELECT s.id, p.id, root.id, "); | |||
sb.append("SELECT s.id, p.id, root.uuid, "); | |||
sb.append(filter.sort().column()); | |||
sb.append(" FROM snapshots s"); | |||
sb.append(" INNER JOIN projects p ON s.component_uuid=p.uuid "); | |||
@@ -134,7 +134,7 @@ class MeasureFilterSql { | |||
private void appendResourceConditions(StringBuilder sb) { | |||
sb.append(" s.status='P' AND s.islast=").append(database.getDialect().getTrueSqlValue()); | |||
if (context.getBaseSnapshot() == null) { | |||
sb.append(" AND p.copy_resource_id IS NULL "); | |||
sb.append(" AND p.copy_component_uuid IS NULL "); | |||
} | |||
if (!filter.getResourceQualifiers().isEmpty()) { | |||
sb.append(" AND s.qualifier IN "); | |||
@@ -259,7 +259,7 @@ class MeasureFilterSql { | |||
static class TextSortRowProcessor extends RowProcessor { | |||
@Override | |||
MeasureFilterRow fetch(ResultSet rs) throws SQLException { | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); | |||
row.setSortText(rs.getString(4)); | |||
return row; | |||
} | |||
@@ -304,7 +304,7 @@ class MeasureFilterSql { | |||
@Override | |||
MeasureFilterRow fetch(ResultSet rs) throws SQLException { | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); | |||
double value = rs.getDouble(4); | |||
if (!rs.wasNull()) { | |||
row.setSortDouble(value); | |||
@@ -333,7 +333,7 @@ class MeasureFilterSql { | |||
@Override | |||
MeasureFilterRow fetch(ResultSet rs) throws SQLException { | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); | |||
row.setSortDate(rs.getTimestamp(4).getTime()); | |||
return row; | |||
} | |||
@@ -352,7 +352,7 @@ class MeasureFilterSql { | |||
@Override | |||
MeasureFilterRow fetch(ResultSet rs) throws SQLException { | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getString(3)); | |||
row.setSortDate(rs.getLong(4)); | |||
return row; | |||
} |
@@ -58,6 +58,8 @@ import static com.google.common.base.MoreObjects.firstNonNull; | |||
import static com.google.common.collect.FluentIterable.from; | |||
import static java.lang.String.format; | |||
import static java.util.Collections.emptyList; | |||
import static java.util.Collections.emptyMap; | |||
import static java.util.Collections.singletonMap; | |||
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01; | |||
import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_KEY; | |||
import static org.sonar.server.component.ComponentFinder.ParamNames.DEVELOPER_ID_AND_KEY; | |||
@@ -156,11 +158,11 @@ public class ComponentAction implements MeasuresWsAction { | |||
} | |||
private Optional<ComponentDto> getReferenceComponent(DbSession dbSession, ComponentDto component) { | |||
if (component.getCopyResourceId() == null) { | |||
if (component.getCopyResourceUuid() == null) { | |||
return Optional.absent(); | |||
} | |||
return dbClient.componentDao().selectById(dbSession, component.getCopyResourceId()); | |||
return dbClient.componentDao().selectByUuid(dbSession, component.getCopyResourceUuid()); | |||
} | |||
private static ComponentWsResponse buildResponse(ComponentWsRequest request, ComponentDto component, Optional<ComponentDto> refComponent, List<MeasureDto> measures, | |||
@@ -172,12 +174,12 @@ public class ComponentAction implements MeasuresWsAction { | |||
MetricDto metric = metricsById.get(measure.getMetricId()); | |||
measuresByMetric.put(metric, measure); | |||
} | |||
Map<Long, ComponentDto> referenceComponentUuidById = new HashMap<>(); | |||
if (refComponent.isPresent()) { | |||
referenceComponentUuidById.put(refComponent.get().getId(), refComponent.get()); | |||
response.setComponent(componentDtoToWsComponent(component, measuresByMetric, singletonMap(refComponent.get().uuid(), refComponent.get()))); | |||
} else { | |||
response.setComponent(componentDtoToWsComponent(component, measuresByMetric, emptyMap())); | |||
} | |||
response.setComponent(componentDtoToWsComponent(component, measuresByMetric, referenceComponentUuidById)); | |||
List<String> additionalFields = request.getAdditionalFields(); | |||
if (additionalFields != null) { |
@@ -33,11 +33,11 @@ class ComponentDtoToWsComponent { | |||
} | |||
static WsMeasures.Component.Builder componentDtoToWsComponent(ComponentDto component, Map<MetricDto, MeasureDto> measuresByMetric, | |||
Map<Long, ComponentDto> referenceComponentsById) { | |||
Map<String, ComponentDto> referenceComponentsByUuid) { | |||
WsMeasures.Component.Builder wsComponent = componentDtoToWsComponent(component); | |||
ComponentDto referenceComponent = referenceComponentsById.get(component.getCopyResourceId()); | |||
if (!referenceComponentsById.isEmpty() && referenceComponent != null) { | |||
ComponentDto referenceComponent = referenceComponentsByUuid.get(component.getCopyResourceUuid()); | |||
if (referenceComponent != null) { | |||
wsComponent.setRefId(referenceComponent.uuid()); | |||
wsComponent.setRefKey(referenceComponent.key()); | |||
} |
@@ -216,13 +216,13 @@ public class ComponentTreeAction implements MeasuresWsAction { | |||
componentDtoToWsComponent( | |||
data.getBaseComponent(), | |||
data.getMeasuresByComponentUuidAndMetric().row(data.getBaseComponent().uuid()), | |||
data.getReferenceComponentsById())); | |||
data.getReferenceComponentsByUuid())); | |||
for (ComponentDto componentDto : data.getComponents()) { | |||
response.addComponents(componentDtoToWsComponent( | |||
componentDto, | |||
data.getMeasuresByComponentUuidAndMetric().row(componentDto.uuid()), | |||
data.getReferenceComponentsById())); | |||
data.getReferenceComponentsByUuid())); | |||
} | |||
if (areMetricsInResponse(request)) { |
@@ -35,7 +35,7 @@ class ComponentTreeData { | |||
private final ComponentDto baseComponent; | |||
private final List<ComponentDtoWithSnapshotId> components; | |||
private final int componentCount; | |||
private final Map<Long, ComponentDto> referenceComponentsById; | |||
private final Map<String, ComponentDto> referenceComponentsByUuid; | |||
private final List<MetricDto> metrics; | |||
private final List<WsMeasures.Period> periods; | |||
private final Table<String, MetricDto, MeasureDto> measuresByComponentUuidAndMetric; | |||
@@ -44,7 +44,7 @@ class ComponentTreeData { | |||
this.baseComponent = builder.baseComponent; | |||
this.components = builder.componentsFromDb; | |||
this.componentCount = builder.componentCount; | |||
this.referenceComponentsById = builder.referenceComponentsById; | |||
this.referenceComponentsByUuid = builder.referenceComponentsByUuid; | |||
this.metrics = builder.metrics; | |||
this.measuresByComponentUuidAndMetric = builder.measuresByComponentUuidAndMetric; | |||
this.periods = builder.periods; | |||
@@ -65,8 +65,8 @@ class ComponentTreeData { | |||
} | |||
@CheckForNull | |||
public Map<Long, ComponentDto> getReferenceComponentsById() { | |||
return referenceComponentsById; | |||
public Map<String, ComponentDto> getReferenceComponentsByUuid() { | |||
return referenceComponentsByUuid; | |||
} | |||
@CheckForNull | |||
@@ -91,7 +91,7 @@ class ComponentTreeData { | |||
static class Builder { | |||
private ComponentDto baseComponent; | |||
private List<ComponentDtoWithSnapshotId> componentsFromDb; | |||
private Map<Long, ComponentDto> referenceComponentsById; | |||
private Map<String, ComponentDto> referenceComponentsByUuid; | |||
private int componentCount; | |||
private List<MetricDto> metrics; | |||
private List<WsMeasures.Period> periods; | |||
@@ -131,8 +131,8 @@ class ComponentTreeData { | |||
return this; | |||
} | |||
public Builder setReferenceComponentsById(Map<Long, ComponentDto> referenceComponentsById) { | |||
this.referenceComponentsById = referenceComponentsById; | |||
public Builder setReferenceComponentsByUuid(Map<String, ComponentDto> referenceComponentsByUuid) { | |||
this.referenceComponentsByUuid = referenceComponentsByUuid; | |||
return this; | |||
} | |||
@@ -24,6 +24,7 @@ import com.google.common.base.Joiner; | |||
import com.google.common.base.Optional; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.base.Predicates; | |||
import com.google.common.collect.FluentIterable; | |||
import com.google.common.collect.HashBasedTable; | |||
import com.google.common.collect.Iterables; | |||
import com.google.common.collect.Lists; | |||
@@ -121,7 +122,7 @@ public class ComponentTreeDataLoader { | |||
components = sortComponents(components, wsRequest, metrics, measuresByComponentUuidAndMetric); | |||
int componentCount = computeComponentCount(componentDtosAndTotal.total, components, componentWithMeasuresOnly(wsRequest)); | |||
components = paginateComponents(components, wsRequest); | |||
Map<Long, ComponentDto> referenceComponentsById = searchReferenceComponentsById(dbSession, components); | |||
Map<String, ComponentDto> referenceComponentsById = searchReferenceComponentsById(dbSession, components); | |||
return ComponentTreeData.builder() | |||
.setBaseComponent(baseComponent) | |||
@@ -130,7 +131,7 @@ public class ComponentTreeDataLoader { | |||
.setMeasuresByComponentUuidAndMetric(measuresByComponentUuidAndMetric) | |||
.setMetrics(metrics) | |||
.setPeriods(periods) | |||
.setReferenceComponentsById(referenceComponentsById) | |||
.setReferenceComponentsByUuid(referenceComponentsById) | |||
.build(); | |||
} finally { | |||
dbClient.closeSession(dbSession); | |||
@@ -150,22 +151,17 @@ public class ComponentTreeDataLoader { | |||
return componentFinder.getByUuidOrKey(dbSession, wsRequest.getDeveloperId(), wsRequest.getDeveloperKey(), DEVELOPER_ID_AND_KEY).getId(); | |||
} | |||
private Map<Long, ComponentDto> searchReferenceComponentsById(DbSession dbSession, List<ComponentDtoWithSnapshotId> components) { | |||
List<Long> referenceComponentIds = from(components) | |||
.transform(ComponentDtoWithSnapshotIdToCopyResourceIdFunction.INSTANCE) | |||
.filter(Predicates.<Long>notNull()) | |||
private Map<String, ComponentDto> searchReferenceComponentsById(DbSession dbSession, List<ComponentDtoWithSnapshotId> components) { | |||
List<String> referenceComponentUUids = from(components) | |||
.transform(ComponentDto::getCopyResourceUuid) | |||
.filter(Predicates.<String>notNull()) | |||
.toList(); | |||
if (referenceComponentIds.isEmpty()) { | |||
if (referenceComponentUUids.isEmpty()) { | |||
return emptyMap(); | |||
} | |||
List<ComponentDto> referenceComponents = dbClient.componentDao().selectByIds(dbSession, referenceComponentIds); | |||
Map<Long, ComponentDto> referenceComponentUuidsById = new HashMap<>(); | |||
for (ComponentDto referenceComponent : referenceComponents) { | |||
referenceComponentUuidsById.put(referenceComponent.getId(), referenceComponent); | |||
} | |||
return referenceComponentUuidsById; | |||
return FluentIterable.from(dbClient.componentDao().selectByUuids(dbSession, referenceComponentUUids)) | |||
.uniqueIndex(ComponentDto::uuid); | |||
} | |||
private ComponentDtosAndTotal searchComponents(DbSession dbSession, ComponentTreeQuery dbQuery, ComponentTreeWsRequest wsRequest) { | |||
@@ -409,15 +405,6 @@ public class ComponentTreeDataLoader { | |||
} | |||
} | |||
private enum ComponentDtoWithSnapshotIdToCopyResourceIdFunction implements Function<ComponentDtoWithSnapshotId, Long> { | |||
INSTANCE; | |||
@Override | |||
public Long apply(@Nonnull ComponentDtoWithSnapshotId input) { | |||
return input.getCopyResourceId(); | |||
} | |||
} | |||
private static class MatchMetricKey implements Predicate<MetricDto> { | |||
private final String metricKeyToSort; | |||
@@ -207,7 +207,7 @@ public class CeQueueImplTest { | |||
} | |||
private static ComponentDto newComponentDto(String uuid) { | |||
return new ComponentDto().setUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); | |||
return new ComponentDto().setUuid(uuid).setRootUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); | |||
} | |||
private CeTask submit(String reportType, String componentUuid) { |
@@ -80,6 +80,7 @@ public class ProjectDataLoaderTest { | |||
underTest.load(ProjectDataQuery.create().setModuleKey(key)); | |||
} | |||
private int uuidCounter = 0; | |||
@Test | |||
public void load_fails_with_BRE_if_component_is_neither_a_project_or_a_module() { | |||
String[][] allScopesAndQualifierButProjectAndModule = { | |||
@@ -96,7 +97,8 @@ public class ProjectDataLoaderTest { | |||
String scope = scopeAndQualifier[0]; | |||
String qualifier = scopeAndQualifier[1]; | |||
String key = "theKey_" + scope + "_" + qualifier; | |||
dbClient.componentDao().insert(dbSession, new ComponentDto().setScope(scope).setQualifier(qualifier).setKey(key)); | |||
String uuid = "uuid_" + uuidCounter++; | |||
dbClient.componentDao().insert(dbSession, new ComponentDto().setUuid(uuid).setRootUuid(uuid).setScope(scope).setQualifier(qualifier).setKey(key)); | |||
dbSession.commit(); | |||
try { |
@@ -85,8 +85,9 @@ public class TaskFormatterTest { | |||
@Test | |||
public void formatQueue_with_component_and_other_fields() throws IOException { | |||
when(ceLogging.getFile(any(LogFileRef.class))).thenReturn(Optional.of(temp.newFile())); | |||
String uuid = "COMPONENT_UUID"; | |||
db.getDbClient().componentDao().insert(db.getSession(), new ComponentDto() | |||
.setUuid("COMPONENT_UUID").setKey("COMPONENT_KEY").setName("Component Name").setQualifier(Qualifiers.PROJECT)); | |||
.setUuid(uuid).setRootUuid(uuid).setKey("COMPONENT_KEY").setName("Component Name").setQualifier(Qualifiers.PROJECT)); | |||
CeQueueDto dto = new CeQueueDto(); | |||
dto.setUuid("UUID"); | |||
@@ -94,14 +95,14 @@ public class TaskFormatterTest { | |||
dto.setStatus(CeQueueDto.Status.IN_PROGRESS); | |||
dto.setCreatedAt(1_450_000_000_000L); | |||
dto.setStartedAt(1_451_000_000_000L); | |||
dto.setComponentUuid("COMPONENT_UUID"); | |||
dto.setComponentUuid(uuid); | |||
dto.setSubmitterLogin("rob"); | |||
WsCe.Task wsTask = underTest.formatQueue(db.getSession(), dto); | |||
assertThat(wsTask.getType()).isEqualTo("TYPE"); | |||
assertThat(wsTask.getId()).isEqualTo("UUID"); | |||
assertThat(wsTask.getComponentId()).isEqualTo("COMPONENT_UUID"); | |||
assertThat(wsTask.getComponentId()).isEqualTo(uuid); | |||
assertThat(wsTask.getComponentKey()).isEqualTo("COMPONENT_KEY"); | |||
assertThat(wsTask.getComponentName()).isEqualTo("Component Name"); | |||
assertThat(wsTask.getComponentQualifier()).isEqualTo("TRK"); |
@@ -123,9 +123,9 @@ public class AppActionTest { | |||
.setProjectUuid("THE_PROJECT") | |||
.setLongName("src/main/java/org/sonar/api/Plugin.java") | |||
.setPath("src/main/java/org/sonar/api/Plugin.java") | |||
.setParentProjectId(5L); | |||
.setRootUuid("uuid_5"); | |||
when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file)); | |||
when(componentDao.selectOrFailById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); | |||
when(componentDao.selectOrFailByUuid(session, "uuid_5")).thenReturn(new ComponentDto().setUuid("uuid_5").setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); | |||
when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); | |||
when(propertiesDao.selectByQuery(any(PropertyQuery.class), eq(session))).thenReturn(newArrayList(new PropertyDto())); | |||
@@ -227,9 +227,9 @@ public class AppActionTest { | |||
.setName("Plugin.java") | |||
.setLongName("src/main/java/org/sonar/api/Plugin.java") | |||
.setPath("src/main/java/org/sonar/api/Plugin.java") | |||
.setParentProjectId(5L); | |||
.setRootUuid("uuid_5"); | |||
when(componentDao.selectByUuid(session, COMPONENT_UUID)).thenReturn(Optional.of(file)); | |||
when(componentDao.selectOrFailById(session, 5L)).thenReturn(new ComponentDto().setId(5L).setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); | |||
when(componentDao.selectOrFailByUuid(session, "uuid_5")).thenReturn(new ComponentDto().setUuid("uuid_5").setLongName("SonarQube :: Plugin API").setKey(SUB_PROJECT_KEY)); | |||
when(componentDao.selectOrFailByUuid(session, project.uuid())).thenReturn(project); | |||
return file; | |||
} |
@@ -402,6 +402,7 @@ public class TreeActionTest { | |||
JsonObject componentAsJsonObject = componentAsJsonElement.getAsJsonObject(); | |||
componentDb.insertComponentAndSnapshot(new ComponentDto() | |||
.setUuid(getJsonField(componentAsJsonObject, "id")) | |||
.setRootUuid("root_uuid") | |||
.setKey(getJsonField(componentAsJsonObject, "key")) | |||
.setName(getJsonField(componentAsJsonObject, "name")) | |||
.setLanguage(getJsonField(componentAsJsonObject, "language")) |
@@ -307,7 +307,7 @@ public class InternalCeQueueImplTest { | |||
} | |||
private static ComponentDto newComponentDto(String uuid) { | |||
return new ComponentDto().setUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); | |||
return new ComponentDto().setUuid(uuid).setRootUuid(uuid).setName("name_" + uuid).setKey("key_" + uuid); | |||
} | |||
private CeTask submit(String reportType, String componentUuid) { |
@@ -391,7 +391,7 @@ public class PersistMeasuresStepTest extends BaseStepTest { | |||
} | |||
private ComponentDto addComponent(String key, String uuid) { | |||
ComponentDto componentDto = new ComponentDto().setKey(key).setUuid(uuid); | |||
ComponentDto componentDto = new ComponentDto().setKey(key).setUuid(uuid).setRootUuid(uuid); | |||
dbClient.componentDao().insert(dbTester.getSession(), componentDto); | |||
return componentDto; | |||
} |
@@ -117,7 +117,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(projectDto.projectUuid()).isEqualTo(projectDto.uuid()); | |||
assertThat(projectDto.qualifier()).isEqualTo("TRK"); | |||
assertThat(projectDto.scope()).isEqualTo("PRJ"); | |||
assertThat(projectDto.parentProjectId()).isNull(); | |||
assertThat(projectDto.getRootUuid()).isEqualTo("ABCD"); | |||
assertThat(projectDto.getCreatedAt()).isEqualTo(now); | |||
ComponentDto moduleDto = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); | |||
@@ -130,7 +130,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(moduleDto.projectUuid()).isEqualTo(projectDto.uuid()); | |||
assertThat(moduleDto.qualifier()).isEqualTo("BRC"); | |||
assertThat(moduleDto.scope()).isEqualTo("PRJ"); | |||
assertThat(moduleDto.parentProjectId()).isEqualTo(projectDto.getId()); | |||
assertThat(moduleDto.getRootUuid()).isEqualTo(projectDto.uuid()); | |||
assertThat(moduleDto.getCreatedAt()).isEqualTo(now); | |||
ComponentDto directoryDto = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); | |||
@@ -143,7 +143,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(directoryDto.projectUuid()).isEqualTo(projectDto.uuid()); | |||
assertThat(directoryDto.qualifier()).isEqualTo("DIR"); | |||
assertThat(directoryDto.scope()).isEqualTo("DIR"); | |||
assertThat(directoryDto.parentProjectId()).isEqualTo(moduleDto.getId()); | |||
assertThat(directoryDto.getRootUuid()).isEqualTo(moduleDto.uuid()); | |||
assertThat(directoryDto.getCreatedAt()).isEqualTo(now); | |||
ComponentDto fileDto = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get(); | |||
@@ -157,7 +157,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(fileDto.projectUuid()).isEqualTo(projectDto.uuid()); | |||
assertThat(fileDto.qualifier()).isEqualTo("FIL"); | |||
assertThat(fileDto.scope()).isEqualTo("FIL"); | |||
assertThat(fileDto.parentProjectId()).isEqualTo(moduleDto.getId()); | |||
assertThat(fileDto.getRootUuid()).isEqualTo(moduleDto.uuid()); | |||
assertThat(fileDto.getCreatedAt()).isEqualTo(now); | |||
assertThat(dbIdsRepository.getComponentId(project)).isEqualTo(projectDto.getId()); | |||
@@ -254,23 +254,23 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid()); | |||
assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); | |||
assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid()); | |||
assertThat(moduleReloaded.parentProjectId()).isEqualTo(module.parentProjectId()); | |||
assertThat(moduleReloaded.getRootUuid()).isEqualTo(module.getRootUuid()); | |||
ComponentDto directory = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); | |||
assertThat(directory.moduleUuid()).isEqualTo(module.uuid()); | |||
assertThat(directory.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); | |||
assertThat(directory.projectUuid()).isEqualTo(project.uuid()); | |||
assertThat(directory.parentProjectId()).isEqualTo(module.getId()); | |||
assertThat(directory.getRootUuid()).isEqualTo(module.uuid()); | |||
ComponentDto file = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get(); | |||
assertThat(file.moduleUuid()).isEqualTo(module.uuid()); | |||
assertThat(file.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); | |||
assertThat(file.projectUuid()).isEqualTo(project.uuid()); | |||
assertThat(file.parentProjectId()).isEqualTo(module.getId()); | |||
assertThat(file.getRootUuid()).isEqualTo(module.uuid()); | |||
} | |||
@Test | |||
public void compute_parent_project_id() { | |||
public void compute_root_uuid() { | |||
treeRootHolder.setRoot( | |||
builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) | |||
.setName("Project") | |||
@@ -298,23 +298,23 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
Optional<ComponentDto> project = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY); | |||
assertThat(project).isPresent(); | |||
assertThat(project.get().parentProjectId()).isNull(); | |||
assertThat(project.get().getRootUuid()).isEqualTo("ABCD"); | |||
Optional<ComponentDto> module = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY"); | |||
assertThat(module).isPresent(); | |||
assertThat(module.get().parentProjectId()).isEqualTo(project.get().getId()); | |||
assertThat(module.get().getRootUuid()).isEqualTo(project.get().uuid()); | |||
Optional<ComponentDto> subModule1 = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_1_KEY"); | |||
assertThat(subModule1).isPresent(); | |||
assertThat(subModule1.get().parentProjectId()).isEqualTo(project.get().getId()); | |||
assertThat(subModule1.get().getRootUuid()).isEqualTo(project.get().uuid()); | |||
Optional<ComponentDto> subModule2 = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_2_KEY"); | |||
assertThat(subModule2).isPresent(); | |||
assertThat(subModule2.get().parentProjectId()).isEqualTo(project.get().getId()); | |||
assertThat(subModule2.get().getRootUuid()).isEqualTo(project.get().uuid()); | |||
Optional<ComponentDto> directory = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_2_KEY:src/main/java/dir"); | |||
assertThat(directory).isPresent(); | |||
assertThat(directory.get().parentProjectId()).isEqualTo(subModule2.get().getId()); | |||
assertThat(directory.get().getRootUuid()).isEqualTo(subModule2.get().uuid()); | |||
} | |||
@Test | |||
@@ -342,22 +342,22 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
ComponentDto project = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get(); | |||
assertThat(project.moduleUuid()).isNull(); | |||
assertThat(project.moduleUuidPath()).isEqualTo("." + project.uuid() + "."); | |||
assertThat(project.parentProjectId()).isNull(); | |||
assertThat(project.getRootUuid()).isEqualTo("ABCD"); | |||
ComponentDto moduleA = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_A").get(); | |||
assertThat(moduleA.moduleUuid()).isEqualTo(project.uuid()); | |||
assertThat(moduleA.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleA.uuid() + "."); | |||
assertThat(moduleA.parentProjectId()).isEqualTo(project.getId()); | |||
assertThat(moduleA.getRootUuid()).isEqualTo(project.uuid()); | |||
ComponentDto subModuleA = dbClient.componentDao().selectByKey(dbTester.getSession(), "SUB_MODULE_A").get(); | |||
assertThat(subModuleA.moduleUuid()).isEqualTo(moduleA.uuid()); | |||
assertThat(subModuleA.moduleUuidPath()).isEqualTo(moduleA.moduleUuidPath() + subModuleA.uuid() + "."); | |||
assertThat(subModuleA.parentProjectId()).isEqualTo(project.getId()); | |||
assertThat(subModuleA.getRootUuid()).isEqualTo(project.uuid()); | |||
ComponentDto moduleB = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B").get(); | |||
assertThat(moduleB.moduleUuid()).isEqualTo(project.uuid()); | |||
assertThat(moduleB.moduleUuidPath()).isEqualTo(project.moduleUuidPath() + moduleB.uuid() + "."); | |||
assertThat(moduleB.parentProjectId()).isEqualTo(project.getId()); | |||
assertThat(moduleB.getRootUuid()).isEqualTo(project.uuid()); | |||
} | |||
@Test | |||
@@ -402,7 +402,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(projectReloaded.moduleUuid()).isEqualTo(project.moduleUuid()); | |||
assertThat(projectReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath()); | |||
assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid()); | |||
assertThat(projectReloaded.parentProjectId()).isEqualTo(project.parentProjectId()); | |||
assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid()); | |||
ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); | |||
assertThat(moduleReloaded.getId()).isEqualTo(module.getId()); | |||
@@ -410,14 +410,14 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid()); | |||
assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(module.moduleUuidPath()); | |||
assertThat(moduleReloaded.projectUuid()).isEqualTo(module.projectUuid()); | |||
assertThat(moduleReloaded.parentProjectId()).isEqualTo(module.parentProjectId()); | |||
assertThat(moduleReloaded.getRootUuid()).isEqualTo(module.getRootUuid()); | |||
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); | |||
assertThat(directoryReloaded.uuid()).isEqualTo(directory.uuid()); | |||
assertThat(directoryReloaded.moduleUuid()).isEqualTo(directory.moduleUuid()); | |||
assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(directory.moduleUuidPath()); | |||
assertThat(directoryReloaded.projectUuid()).isEqualTo(directory.projectUuid()); | |||
assertThat(directoryReloaded.parentProjectId()).isEqualTo(directory.parentProjectId()); | |||
assertThat(directoryReloaded.getRootUuid()).isEqualTo(directory.getRootUuid()); | |||
assertThat(directoryReloaded.name()).isEqualTo(directory.name()); | |||
assertThat(directoryReloaded.path()).isEqualTo(directory.path()); | |||
@@ -426,7 +426,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(fileReloaded.moduleUuid()).isEqualTo(file.moduleUuid()); | |||
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(file.moduleUuidPath()); | |||
assertThat(fileReloaded.projectUuid()).isEqualTo(file.projectUuid()); | |||
assertThat(fileReloaded.parentProjectId()).isEqualTo(file.parentProjectId()); | |||
assertThat(fileReloaded.getRootUuid()).isEqualTo(file.getRootUuid()); | |||
assertThat(fileReloaded.name()).isEqualTo(file.name()); | |||
assertThat(fileReloaded.path()).isEqualTo(file.path()); | |||
} | |||
@@ -555,7 +555,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(moduleBReloaded.moduleUuid()).isEqualTo(moduleAreloaded.uuid()); | |||
assertThat(moduleBReloaded.moduleUuidPath()).isEqualTo(moduleAreloaded.moduleUuidPath() + moduleBReloaded.uuid() + "."); | |||
assertThat(moduleBReloaded.projectUuid()).isEqualTo(project.uuid()); | |||
assertThat(moduleBReloaded.parentProjectId()).isEqualTo(project.getId()); | |||
assertThat(moduleBReloaded.getRootUuid()).isEqualTo(project.uuid()); | |||
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B:src/main/java/dir").get(); | |||
assertThat(directoryReloaded).isNotNull(); | |||
@@ -563,7 +563,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(directoryReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid()); | |||
assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath()); | |||
assertThat(directoryReloaded.projectUuid()).isEqualTo(project.uuid()); | |||
assertThat(directoryReloaded.parentProjectId()).isEqualTo(moduleBReloaded.getId()); | |||
assertThat(directoryReloaded.getRootUuid()).isEqualTo(moduleBReloaded.uuid()); | |||
ComponentDto fileReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_B:src/main/java/dir/Foo.java").get(); | |||
assertThat(fileReloaded).isNotNull(); | |||
@@ -571,7 +571,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleBReloaded.uuid()); | |||
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleBReloaded.moduleUuidPath()); | |||
assertThat(fileReloaded.projectUuid()).isEqualTo(project.uuid()); | |||
assertThat(fileReloaded.parentProjectId()).isEqualTo(moduleBReloaded.getId()); | |||
assertThat(fileReloaded.getRootUuid()).isEqualTo(moduleBReloaded.uuid()); | |||
} | |||
@Test | |||
@@ -638,7 +638,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(projectReloaded.moduleUuid()).isEqualTo(project.moduleUuid()); | |||
assertThat(projectReloaded.moduleUuidPath()).isEqualTo(project.moduleUuidPath()); | |||
assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid()); | |||
assertThat(projectReloaded.parentProjectId()).isEqualTo(project.parentProjectId()); | |||
assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid()); | |||
assertThat(projectReloaded.isEnabled()).isTrue(); | |||
ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); | |||
@@ -647,7 +647,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(moduleReloaded.moduleUuid()).isEqualTo(removedModule.moduleUuid()); | |||
assertThat(moduleReloaded.moduleUuidPath()).isEqualTo(removedModule.moduleUuidPath()); | |||
assertThat(moduleReloaded.projectUuid()).isEqualTo(removedModule.projectUuid()); | |||
assertThat(moduleReloaded.parentProjectId()).isEqualTo(removedModule.parentProjectId()); | |||
assertThat(moduleReloaded.getRootUuid()).isEqualTo(removedModule.getRootUuid()); | |||
assertThat(moduleReloaded.isEnabled()).isTrue(); | |||
ComponentDto directoryReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get(); | |||
@@ -656,7 +656,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(directoryReloaded.moduleUuid()).isEqualTo(removedDirectory.moduleUuid()); | |||
assertThat(directoryReloaded.moduleUuidPath()).isEqualTo(removedDirectory.moduleUuidPath()); | |||
assertThat(directoryReloaded.projectUuid()).isEqualTo(removedDirectory.projectUuid()); | |||
assertThat(directoryReloaded.parentProjectId()).isEqualTo(removedDirectory.parentProjectId()); | |||
assertThat(directoryReloaded.getRootUuid()).isEqualTo(removedDirectory.getRootUuid()); | |||
assertThat(directoryReloaded.name()).isEqualTo(removedDirectory.name()); | |||
assertThat(directoryReloaded.path()).isEqualTo(removedDirectory.path()); | |||
assertThat(directoryReloaded.isEnabled()).isTrue(); | |||
@@ -667,7 +667,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(fileReloaded.moduleUuid()).isEqualTo(removedFile.moduleUuid()); | |||
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(removedFile.moduleUuidPath()); | |||
assertThat(fileReloaded.projectUuid()).isEqualTo(removedFile.projectUuid()); | |||
assertThat(fileReloaded.parentProjectId()).isEqualTo(removedFile.parentProjectId()); | |||
assertThat(fileReloaded.getRootUuid()).isEqualTo(removedFile.getRootUuid()); | |||
assertThat(fileReloaded.name()).isEqualTo(removedFile.name()); | |||
assertThat(fileReloaded.path()).isEqualTo(removedFile.path()); | |||
assertThat(fileReloaded.isEnabled()).isTrue(); | |||
@@ -717,7 +717,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleReloaded.uuid()); | |||
assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleReloaded.moduleUuidPath()); | |||
assertThat(fileReloaded.projectUuid()).isEqualTo(moduleReloaded.projectUuid()); | |||
assertThat(fileReloaded.parentProjectId()).isEqualTo(moduleReloaded.getId()); | |||
assertThat(fileReloaded.getRootUuid()).isEqualTo(moduleReloaded.uuid()); | |||
assertThat(fileReloaded.name()).isEqualTo(removedFile.name()); | |||
assertThat(fileReloaded.path()).isEqualTo(removedFile.path()); | |||
assertThat(fileReloaded.isEnabled()).isTrue(); |
@@ -300,7 +300,7 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
.setUuid(PROJECT_VIEW_1_UUID) | |||
.setName(PROJECT_VIEW_1_NAME) | |||
.setDescription("project view description is not persisted") | |||
.setProjectViewAttributes(new ProjectViewAttributes(project.getId(), project.uuid())); | |||
.setProjectViewAttributes(new ProjectViewAttributes(project.uuid())); | |||
} | |||
private void persistComponents(ComponentDto... componentDtos) { | |||
@@ -333,12 +333,12 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(projectDto.path()).isNull(); | |||
assertThat(projectDto.uuid()).isEqualTo(VIEW_UUID); | |||
assertThat(projectDto.projectUuid()).isEqualTo(projectDto.uuid()); | |||
assertThat(projectDto.parentProjectId()).isNull(); | |||
assertThat(projectDto.getRootUuid()).isEqualTo(VIEW_UUID); | |||
assertThat(projectDto.moduleUuid()).isNull(); | |||
assertThat(projectDto.moduleUuidPath()).isEqualTo("." + projectDto.uuid() + "."); | |||
assertThat(projectDto.qualifier()).isEqualTo(Qualifiers.VIEW); | |||
assertThat(projectDto.scope()).isEqualTo(Scopes.PROJECT); | |||
assertThat(projectDto.getCopyResourceId()).isNull(); | |||
assertThat(projectDto.getCopyResourceUuid()).isNull(); | |||
assertThat(projectDto.getCreatedAt()).isEqualTo(now); | |||
} | |||
@@ -352,12 +352,12 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(sv1Dto.path()).isNull(); | |||
assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID); | |||
assertThat(sv1Dto.projectUuid()).isEqualTo(viewDto.uuid()); | |||
assertThat(sv1Dto.parentProjectId()).isEqualTo(viewDto.getId()); | |||
assertThat(sv1Dto.getRootUuid()).isEqualTo(viewDto.uuid()); | |||
assertThat(sv1Dto.moduleUuid()).isEqualTo(viewDto.uuid()); | |||
assertThat(sv1Dto.moduleUuidPath()).isEqualTo(viewDto.moduleUuidPath() + sv1Dto.uuid() + "."); | |||
assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW); | |||
assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT); | |||
assertThat(sv1Dto.getCopyResourceId()).isNull(); | |||
assertThat(sv1Dto.getCopyResourceUuid()).isNull(); | |||
assertThat(sv1Dto.getCreatedAt()).isEqualTo(now); | |||
} | |||
@@ -368,12 +368,12 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { | |||
assertThat(pv1Dto.path()).isNull(); | |||
assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID); | |||
assertThat(pv1Dto.projectUuid()).isEqualTo(viewDto.uuid()); | |||
assertThat(pv1Dto.parentProjectId()).isEqualTo(viewDto.getId()); | |||
assertThat(pv1Dto.getRootUuid()).isEqualTo(viewDto.uuid()); | |||
assertThat(pv1Dto.moduleUuid()).isEqualTo(parentViewDto.uuid()); | |||
assertThat(pv1Dto.moduleUuidPath()).isEqualTo(parentViewDto.moduleUuidPath() + pv1Dto.uuid() + "."); | |||
assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT); | |||
assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE); | |||
assertThat(pv1Dto.getCopyResourceId()).isEqualTo(project.getId()); | |||
assertThat(pv1Dto.getCopyResourceUuid()).isEqualTo(project.uuid()); | |||
assertThat(pv1Dto.getCreatedAt()).isEqualTo(now); | |||
} | |||
@@ -70,14 +70,14 @@ public class DuplicationsJsonWriterTest { | |||
@Test | |||
public void write_duplications() { | |||
String key1 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java"; | |||
ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery").setParentProjectId(5L); | |||
ComponentDto file1 = ComponentTesting.newFileDto(project).setId(10L).setKey(key1).setLongName("PropertyDeleteQuery").setRootUuid("uuid_5"); | |||
String key2 = "org.codehaus.sonar:sonar-ws-client:src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java"; | |||
ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setParentProjectId(5L); | |||
ComponentDto file2 = ComponentTesting.newFileDto(project).setId(11L).setQualifier("FIL").setKey(key2).setLongName("PropertyUpdateQuery").setRootUuid("uuid_5"); | |||
when(componentDao.selectByKey(session, key1)).thenReturn(Optional.of(file1)); | |||
when(componentDao.selectByKey(session, key2)).thenReturn(Optional.of(file2)); | |||
when(componentDao.selectById(session, 5L)).thenReturn(Optional.of( | |||
new ComponentDto().setId(5L).setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client"))); | |||
when(componentDao.selectByUuid(session, "uuid_5")).thenReturn(Optional.of( | |||
new ComponentDto().setUuid("uuid_5").setKey("org.codehaus.sonar:sonar-ws-client").setLongName("SonarQube :: Web Service Client"))); | |||
when(componentDao.selectByUuid(session, project.uuid())).thenReturn(Optional.of(project)); | |||
List<DuplicationsParser.Block> blocks = newArrayList(); | |||
@@ -123,7 +123,7 @@ public class DuplicationsJsonWriterTest { | |||
verify(componentDao, times(2)).selectByKey(eq(session), anyString()); | |||
// Verify call to dao is cached when searching for project / sub project | |||
verify(componentDao, times(1)).selectByUuid(eq(session), eq(project.uuid())); | |||
verify(componentDao, times(1)).selectById(eq(session), eq(5L)); | |||
verify(componentDao, times(1)).selectByUuid(eq(session), eq("uuid_5")); | |||
} | |||
@Test |
@@ -347,16 +347,12 @@ public class IssueQueryServiceTest { | |||
String login2 = "darth.vader"; | |||
String copyProjectUuid = devUuid + ":" + projectUuid; | |||
long copyResourceId = 42L; | |||
ComponentDto technicalProject = new ComponentDto().setProjectUuid(devUuid).setCopyResourceId(copyResourceId); | |||
ComponentDto technicalProject = new ComponentDto().setProjectUuid(devUuid).setCopyComponentUuid(projectUuid); | |||
when(componentDao.selectByUuids(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(technicalProject)); | |||
when(componentService.getDistinctQualifiers(isA(DbSession.class), anyCollection())).thenReturn(Sets.newHashSet("DEV_PRJ")); | |||
when(authorDao.selectScmAccountsByDeveloperUuids(isA(DbSession.class), anyCollection())).thenReturn(Lists.newArrayList(login1, login2)); | |||
ComponentDto actualProject = new ComponentDto().setUuid(projectUuid); | |||
when(componentDao.selectByIds(isA(DbSession.class), anyCollection())).thenReturn(Arrays.asList(actualProject)); | |||
Map<String, Object> map = newHashMap(); | |||
map.put("componentUuids", newArrayList(copyProjectUuid)); | |||
IssueQuery query = underTest.createFromMap(map); |
@@ -19,6 +19,9 @@ | |||
*/ | |||
package org.sonar.server.measure; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import java.sql.SQLException; | |||
import java.util.Arrays; | |||
import java.util.Date; | |||
@@ -34,20 +37,19 @@ import org.sonar.db.DbTester; | |||
import org.sonar.db.component.ResourceDao; | |||
import org.sonar.db.component.SnapshotDto; | |||
import static com.google.common.collect.Lists.newArrayList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
public class MeasureFilterExecutorTest { | |||
private static final long JAVA_PROJECT_ID = 1L; | |||
private static final long JAVA_FILE_BIG_ID = 3L; | |||
private static final long JAVA_FILE_TINY_ID = 4L; | |||
private static final String JAVA_PROJECT_UUID = "UUID_JAVA_PROJECT"; | |||
private static final long JAVA_PROJECT_SNAPSHOT_ID = 101L; | |||
private static final long JAVA_FILE_BIG_SNAPSHOT_ID = 103L; | |||
private static final long JAVA_FILE_TINY_SNAPSHOT_ID = 104L; | |||
private static final long JAVA_PACKAGE_SNAPSHOT_ID = 102L; | |||
private static final long PHP_PROJECT_ID = 10L; | |||
private static final String PHP_PROJECT_UUID = "UUID_PHP_PROJECT"; | |||
private static final long PHP_SNAPSHOT_ID = 110L; | |||
private static final Metric METRIC_LINES = new Metric.Builder("lines", "Lines", Metric.ValueType.INT).create().setId(1); | |||
private static final Metric METRIC_PROFILE = new Metric.Builder("profile", "Profile", Metric.ValueType.STRING).create().setId(2); | |||
@@ -373,7 +375,7 @@ public class MeasureFilterExecutorTest { | |||
assertThat(rows).hasSize(3); | |||
verifyPhpProject(rows.get(0)); | |||
verifyJavaProject(rows.get(1)); | |||
verifyProject(rows.get(2), 120L, 20L, 20L); | |||
verifyProject(rows.get(2), 120L, 20L, "CDEF"); | |||
} | |||
@Test | |||
@@ -386,7 +388,7 @@ public class MeasureFilterExecutorTest { | |||
// Js Project ERROR, Java Project WARN, then Php Project OK | |||
assertThat(rows).hasSize(3); | |||
verifyProject(rows.get(0), 120L, 20L, 20L); | |||
verifyProject(rows.get(0), 120L, 20L, "CDEF"); | |||
verifyJavaProject(rows.get(1)); | |||
verifyPhpProject(rows.get(2)); | |||
} | |||
@@ -589,24 +591,24 @@ public class MeasureFilterExecutorTest { | |||
} | |||
private void verifyJavaProject(MeasureFilterRow row) { | |||
verifyProject(row, JAVA_PROJECT_SNAPSHOT_ID, JAVA_PROJECT_ID, JAVA_PROJECT_ID); | |||
verifyProject(row, JAVA_PROJECT_SNAPSHOT_ID, JAVA_PROJECT_ID, JAVA_PROJECT_UUID); | |||
} | |||
private void verifyJavaBigFile(MeasureFilterRow row) { | |||
verifyProject(row, JAVA_FILE_BIG_SNAPSHOT_ID, JAVA_FILE_BIG_ID, JAVA_PROJECT_ID); | |||
verifyProject(row, JAVA_FILE_BIG_SNAPSHOT_ID, JAVA_FILE_BIG_ID, JAVA_PROJECT_UUID); | |||
} | |||
private void verifyJavaTinyFile(MeasureFilterRow row) { | |||
verifyProject(row, JAVA_FILE_TINY_SNAPSHOT_ID, JAVA_FILE_TINY_ID, JAVA_PROJECT_ID); | |||
verifyProject(row, JAVA_FILE_TINY_SNAPSHOT_ID, JAVA_FILE_TINY_ID, JAVA_PROJECT_UUID); | |||
} | |||
private void verifyPhpProject(MeasureFilterRow row) { | |||
verifyProject(row, PHP_SNAPSHOT_ID, PHP_PROJECT_ID, PHP_PROJECT_ID); | |||
verifyProject(row, PHP_SNAPSHOT_ID, PHP_PROJECT_ID, PHP_PROJECT_UUID); | |||
} | |||
private void verifyProject(MeasureFilterRow row, Long snashotId, Long resourceId, Long resourceRootId) { | |||
private void verifyProject(MeasureFilterRow row, Long snashotId, Long resourceId, String rootComponentUuid) { | |||
assertThat(row.getSnapshotId()).isEqualTo(snashotId); | |||
assertThat(row.getResourceId()).isEqualTo(resourceId); | |||
assertThat(row.getResourceRootId()).isEqualTo(resourceRootId); | |||
assertThat(row.getRootComponentUuid()).isEqualTo(rootComponentUuid); | |||
} | |||
} |
@@ -336,6 +336,7 @@ public class QProfileFactoryMediumTest { | |||
ComponentDto project = new ComponentDto() | |||
.setId(1L) | |||
.setUuid("ABCD") | |||
.setRootUuid("ABCD") | |||
.setKey("org.codehaus.sonar:sonar") | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") |
@@ -68,6 +68,7 @@ public class QProfileProjectOperationsMediumTest { | |||
project = new ComponentDto() | |||
.setUuid(PROJECT_UUID) | |||
.setRootUuid(PROJECT_UUID) | |||
.setKey(PROJECT_KEY) | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") | |||
@@ -123,6 +124,7 @@ public class QProfileProjectOperationsMediumTest { | |||
public void remove_all_projects() { | |||
ComponentDto project1 = new ComponentDto() | |||
.setUuid("BCDE") | |||
.setRootUuid("BCDE") | |||
.setKey("project1") | |||
.setName("project1") | |||
.setLongName("project1") | |||
@@ -131,6 +133,7 @@ public class QProfileProjectOperationsMediumTest { | |||
.setEnabled(true); | |||
ComponentDto project2 = new ComponentDto() | |||
.setUuid("CDEF") | |||
.setRootUuid("CDEF") | |||
.setKey("project2") | |||
.setName("project2") | |||
.setLongName("project2") |
@@ -444,6 +444,7 @@ public class QProfilesWsMediumTest { | |||
ComponentDto project = new ComponentDto() | |||
.setId(1L) | |||
.setUuid("ABCD") | |||
.setRootUuid("ABCD") | |||
.setKey("org.codehaus.sonar:sonar") | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") | |||
@@ -473,6 +474,7 @@ public class QProfilesWsMediumTest { | |||
ComponentDto project = new ComponentDto() | |||
.setId(1L) | |||
.setUuid("ABCD") | |||
.setRootUuid("ABCD") | |||
.setKey("org.codehaus.sonar:sonar") | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") | |||
@@ -498,6 +500,7 @@ public class QProfilesWsMediumTest { | |||
ComponentDto project = new ComponentDto() | |||
.setId(1L) | |||
.setUuid("ABCD") | |||
.setRootUuid("ABCD") | |||
.setKey("org.codehaus.sonar:sonar") | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") | |||
@@ -563,6 +566,7 @@ public class QProfilesWsMediumTest { | |||
ComponentDto project = new ComponentDto() | |||
.setId(1L) | |||
.setUuid("ABCD") | |||
.setRootUuid("ABCD") | |||
.setKey("org.codehaus.sonar:sonar") | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") | |||
@@ -587,6 +591,7 @@ public class QProfilesWsMediumTest { | |||
ComponentDto project = new ComponentDto() | |||
.setId(1L) | |||
.setUuid("ABCD") | |||
.setRootUuid("ABCD") | |||
.setKey("org.codehaus.sonar:sonar") | |||
.setName("SonarQube") | |||
.setLongName("SonarQube") |
@@ -116,6 +116,7 @@ public class ListActionTest { | |||
TestFile2.dto(), | |||
new ComponentDto() | |||
.setUuid(mainFileUuid) | |||
.setRootUuid(TestFile1.PROJECT_UUID) | |||
.setProjectUuid(TestFile1.PROJECT_UUID)); | |||
db.getSession().commit(); | |||
@@ -140,6 +141,7 @@ public class ListActionTest { | |||
TestFile2.dto(), | |||
new ComponentDto() | |||
.setUuid(sourceFileUuid) | |||
.setRootUuid(TestFile1.PROJECT_UUID) | |||
.setKey(sourceFileKey) | |||
.setProjectUuid(TestFile1.PROJECT_UUID)); | |||
db.getSession().commit(); | |||
@@ -192,7 +194,7 @@ public class ListActionTest { | |||
public void fail_when_no_sufficient_privilege_on_main_file_uuid() throws Exception { | |||
userSessionRule.addProjectUuidPermissions(UserRole.USER, TestFile1.PROJECT_UUID); | |||
String mainFileUuid = "MAIN-FILE-UUID"; | |||
dbClient.componentDao().insert(db.getSession(), new ComponentDto().setUuid(mainFileUuid).setProjectUuid(TestFile1.PROJECT_UUID)); | |||
dbClient.componentDao().insert(db.getSession(), new ComponentDto().setUuid(mainFileUuid).setRootUuid(TestFile1.PROJECT_UUID).setProjectUuid(TestFile1.PROJECT_UUID)); | |||
db.getSession().commit(); | |||
ws.newGetRequest("api/tests", "list") | |||
@@ -227,6 +229,7 @@ public class ListActionTest { | |||
public static ComponentDto dto() { | |||
return new ComponentDto() | |||
.setUuid(TestFile1.FILE_UUID) | |||
.setRootUuid(TestFile1.PROJECT_UUID) | |||
.setLongName(TestFile1.LONG_NAME) | |||
.setProjectUuid(TestFile1.PROJECT_UUID) | |||
.setKey(TestFile1.KEY); | |||
@@ -266,6 +269,7 @@ public class ListActionTest { | |||
public static ComponentDto dto() { | |||
return new ComponentDto() | |||
.setUuid(TestFile2.FILE_UUID) | |||
.setRootUuid(TestFile2.PROJECT_UUID) | |||
.setLongName(TestFile2.LONG_NAME) | |||
.setProjectUuid(TestFile2.PROJECT_UUID) | |||
.setKey(TestFile2.KEY); |
@@ -4,24 +4,24 @@ | |||
<group_roles id="1" group_id="[null]" resource_id="100" role="user"/> | |||
<!-- View --> | |||
<projects id="11" uuid="EFGH" project_uuid="EFGH" module_uuid="[null]" module_uuid_path="." copy_resource_id="[null]" enabled="[true]" | |||
<projects id="11" uuid="EFGH" root_uuid="EFGH" project_uuid="EFGH" module_uuid="[null]" module_uuid_path="." copy_component_uuid="[null]" enabled="[true]" | |||
kee="LANGUAGE_VIEW" scope="PRJ" qualifier="VW" name="By Language" path="[null]"/> | |||
<projects id="112" uuid="GHIJ" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_resource_id="101" enabled="[true]" | |||
<projects id="112" uuid="GHIJ" root_uuid="EFGH" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_component_uuid="KLMN" enabled="[true]" | |||
kee="VIEW2org.elasticsearch:elasticsearch" scope="FIL" qualifier="TRK" name="Elasticsearch" path="[null]"/> | |||
<projects id="113" uuid="HIJK" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_resource_id="100" enabled="[true]" | |||
<projects id="113" uuid="HIJK" root_uuid="EFGH" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_component_uuid="JKLM" enabled="[true]" | |||
kee="VIEW2org.struts:struts" scope="FIL" qualifier="TRK" name="Struts" path="[null]"/> | |||
<!-- Real projects --> | |||
<projects id="100" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_resource_id="[null]" path="[null]"/> | |||
uuid="JKLM" root_uuid="JKLM" root_project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_component_uuid="[null]" path="[null]"/> | |||
<projects id="101" scope="PRJ" qualifier="TRK" kee="org.elasticsearch:elasticsearch" name="Elasticsearch" | |||
uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_resource_id="[null]" path="[null]"/> | |||
uuid="KLMN" root_uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_component_uuid="[null]" path="[null]"/> | |||
<resource_index id="1" kee="struts" component_uuid="JKLM" root_component_uuid="JKLM" position="0" name_size="6" qualifier="TRK"/> | |||
<resource_index id="2" kee="elasticsearch" component_uuid="KLMN" root_component_uuid="KLMN" position="0" name_size="13" qualifier="TRK"/> |
@@ -5,28 +5,28 @@ | |||
<group_roles id="2" group_id="[null]" resource_id="101" role="user"/> | |||
<!-- View with sub view --> | |||
<projects id="11" uuid="EFGH" project_uuid="EFGH" module_uuid="[null]" module_uuid_path="." copy_resource_id="[null]" enabled="[true]" | |||
<projects id="11" uuid="EFGH" root_uuid="EFGH" project_uuid="EFGH" module_uuid="[null]" module_uuid_path="." copy_component_uuid="[null]" enabled="[true]" | |||
kee="LANGUAGE_VIEW" scope="PRJ" qualifier="VW" name="By Language" path="[null]"/> | |||
<projects id="112" uuid="GHIJ" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_resource_id="101" enabled="[true]" | |||
<projects id="112" uuid="GHIJ" root_uuid="EFGH" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_component_uuid="KLMN" enabled="[true]" | |||
kee="VIEW2org.elasticsearch:elasticsearch" scope="FIL" qualifier="TRK" name="Elasticsearch" path="[null]"/> | |||
<!-- Sub view --> | |||
<projects id="13" uuid="FGHI" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_resource_id="[null]" enabled="[true]" | |||
<projects id="13" uuid="FGHI" root_uuid="EFGH" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_component_uuid="[null]" enabled="[true]" | |||
kee="JAVA_PROJECTS" scope="PRJ" qualifier="SVW" name="Java projects" path="[null]"/> | |||
<projects id="113" uuid="HIJK" project_uuid="EFGH" module_uuid="FGHI" module_uuid_path=".EFGH.FGHI." copy_resource_id="100" enabled="[true]" | |||
<projects id="113" uuid="HIJK" root_uuid="EFGH" project_uuid="EFGH" module_uuid="FGHI" module_uuid_path=".EFGH.FGHI." copy_component_uuid="JKLM" enabled="[true]" | |||
kee="VIEW2org.struts:struts" scope="FIL" qualifier="TRK" name="Struts" path="[null]"/> | |||
<!-- Real projects --> | |||
<projects id="100" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_resource_id="[null]" path="[null]"/> | |||
uuid="JKLM" root_uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_component_uuid="[null]" path="[null]"/> | |||
<projects id="101" scope="PRJ" qualifier="TRK" kee="org.elasticsearch:elasticsearch" name="Elasticsearch" | |||
uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_resource_id="[null]" path="[null]"/> | |||
uuid="KLMN" root_uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_component_uuid="[null]" path="[null]"/> | |||
<resource_index id="1" kee="struts" component_uuid="JKLM" root_component_uuid="JKLM" position="0" name_size="6" qualifier="TRK"/> | |||
<resource_index id="2" kee="elasticsearch" component_uuid="KLMN" root_component_uuid="KLMN" position="0" name_size="13" qualifier="TRK"/> |
@@ -1,5 +1,5 @@ | |||
<dataset> | |||
<projects id="567" uuid="uuid_1" kee="file cpt key" enabled="[true]"/> | |||
<projects id="567" uuid="uuid_1" root_uuid="uuid_1" kee="file cpt key" enabled="[true]"/> | |||
<snapshots id="123" component_uuid="uuid_1" root_component_uuid="uuid_1" islast="[true]"/> | |||
<snapshots id="369" component_uuid="uuid_1" root_component_uuid="uuid_1" islast="[false]"/> | |||
<metrics id="1" name="metric 1" /> |
@@ -1,5 +1,5 @@ | |||
<dataset> | |||
<projects id="1" root_id="[null]" kee="ROOT_KEY" uuid="ABCD"/> | |||
<projects id="1" root_uuid="ABCD" kee="ROOT_KEY" uuid="ABCD"/> | |||
</dataset> |
@@ -1,6 +1,6 @@ | |||
<dataset> | |||
<projects id="1" kee="ROOT_KEY" name="project" uuid="ABCD"/> | |||
<projects id="1" kee="ROOT_KEY" name="project" uuid="ABCD" root_uuid="ABCD"/> | |||
<!-- 2008-11-11 --> | |||
<!-- Version 0.9 --> |
@@ -1,6 +1,6 @@ | |||
<dataset> | |||
<projects id="1" root_id="[null]" kee="ROOT_KEY" uuid="ABCD"/> | |||
<projects id="1" kee="ROOT_KEY" uuid="ABCD" root_uuid="ABCD"/> | |||
<!-- 2008-11-11 --> | |||
<!-- Version 0.9 --> |
@@ -1,6 +1,6 @@ | |||
<dataset> | |||
<projects id="1" kee="ROOT_KEY" name="project" uuid="ABCD"/> | |||
<projects id="1" kee="ROOT_KEY" name="project" uuid="ABCD" root_uuid="ABCD"/> | |||
<!-- 2008-11-11 --> | |||
<!-- Version 0.9 --> |
@@ -1,6 +1,6 @@ | |||
<dataset> | |||
<projects id="1" kee="ROOT_KEY" name="project" uuid="ABCD"/> | |||
<projects id="1" kee="ROOT_KEY" name="project" uuid="ABCD" root_uuid="ABCD"/> | |||
<!-- 2008-11-11 --> | |||
<!-- Version 0.9 --> |
@@ -1,8 +1,8 @@ | |||
<dataset> | |||
<projects id="1" root_id="[null]" scope="PRJ" qualifier="TRK" kee="PROJECT_KEY" name="project" long_name="[null]" description="[null]" | |||
<projects id="1" root_uuid="ABCD" scope="PRJ" qualifier="TRK" kee="PROJECT_KEY" name="project" long_name="[null]" description="[null]" | |||
uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path=".ABCD." | |||
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]"/> | |||
enabled="[true]" language="java" /> | |||
<!-- Unprocessed snapshot --> | |||
<snapshots id="1000" purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" period2_mode="[null]" period2_param="[null]" period2_date="[null]" |
@@ -1,7 +1,7 @@ | |||
<dataset> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="ABCD"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="ABCD" root_uuid="ABCD"/> | |||
<snapshots id="10" component_uuid="ABCD" root_component_uuid="ABCD" islast="[true]"/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="BCDE"/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="BCDE" root_uuid="ABCD"/> | |||
<snapshots id="100" component_uuid="BCDE" root_component_uuid="ABCD" islast="[true]"/> | |||
</dataset> |
@@ -1,6 +1,6 @@ | |||
<dataset> | |||
<projects id="1" kee="struts" root_id="[null]" uuid="ABCD"/> | |||
<projects id="2" kee="struts:Action.java" root_id="1" uuid="BCDE"/> | |||
<projects id="1" kee="struts" root_uuid="ABCD" uuid="ABCD"/> | |||
<projects id="2" kee="struts:Action.java" root_uuid="ABCD" uuid="BCDE"/> | |||
<snapshots id="1" component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]" islast="[true]" /> | |||
<snapshots id="2" component_uuid="BCDE" parent_snapshot_id="1" root_component_uuid="ABCD" root_snapshot_id="1" islast="[true]" /> |
@@ -1,7 +1,7 @@ | |||
<dataset> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="ABCD"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="ABCD" root_uuid="ABCD"/> | |||
<snapshots id="10" component_uuid="ABCD" root_component_uuid="ABCD" islast="[true]"/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="BCDE"/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="BCDE" root_uuid="ABCD"/> | |||
<snapshots id="100" component_uuid="BCDE" root_component_uuid="ABCD" islast="[true]"/> | |||
</dataset> |
@@ -1,9 +1,9 @@ | |||
<dataset> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="ABCD"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="ABCD" root_uuid="ABCD"/> | |||
<snapshots id="10" component_uuid="ABCD" root_component_uuid="ABCD" islast="[true]"/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="BCDE"/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="BCDE" root_uuid="ABCD"/> | |||
<snapshots id="100" component_uuid="BCDE" root_component_uuid="ABCD" islast="[true]"/> | |||
<issues id="1" |
@@ -1,9 +1,9 @@ | |||
<dataset> | |||
<projects id="1" uuid="ABC" project_uuid="ABC" module_uuid="[null]" module_uuid_path="." | |||
root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
root_uuid="ABC" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
description="the description" long_name="Apache Struts" | |||
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" | |||
enabled="[true]" language="java" path="[null]" | |||
authorization_updated_at="123456789"/> | |||
<!-- no authorizations project ABC. --> |
@@ -1,15 +1,15 @@ | |||
<dataset> | |||
<projects id="1" uuid="ABC" project_uuid="ABC" module_uuid="[null]" module_uuid_path="." | |||
root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
root_uuid="ABC" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
description="the description" long_name="Apache Struts" | |||
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" | |||
enabled="[true]" language="java" path="[null]" | |||
authorization_updated_at="1000000000"/> | |||
<projects id="2" uuid="DEF" project_uuid="DEF" module_uuid="[null]" module_uuid_path="." | |||
root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.sonar.sample" name="Sample" | |||
root_uuid="ABC" scope="PRJ" qualifier="TRK" kee="org.sonar.sample" name="Sample" | |||
description="the description" long_name="Sample" | |||
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" | |||
enabled="[true]" language="java" path="[null]" | |||
authorization_updated_at="2000000000"/> | |||
<!-- user1 can access both projects --> |
@@ -1,9 +1,9 @@ | |||
<dataset> | |||
<projects id="1" uuid="ABC" project_uuid="ABC" module_uuid="[null]" module_uuid_path="." | |||
root_id="[null]" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
root_uuid="ABC" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
description="the description" long_name="Apache Struts" | |||
enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]" | |||
enabled="[true]" language="java" path="[null]" | |||
authorization_updated_at="123456789"/> | |||
<users id="10" login="user1" name="User 1" email="user1@company.net" active="[true]"/> |
@@ -3,9 +3,9 @@ | |||
plugin_config_key="[null]" plugin_name="squid"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="the_project" name="TheProject" | |||
uuid="THE_PROJECT" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
uuid="THE_PROJECT" root_uuid="THE_PROJECT" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="11" scope="FIL" qualifier="FIL" kee="abcde" name="TheFile" | |||
uuid="THE_FILE" module_uuid="THE_PROJECT" module_uuid_path=".THE_PROJECT." | |||
uuid="THE_FILE" root_uuid="THE_PROJECT" module_uuid="THE_PROJECT" module_uuid_path=".THE_PROJECT." | |||
path="src/main/java/TheFile.java"/> | |||
<issues id="1" |
@@ -4,9 +4,9 @@ | |||
<!-- Project 1 --> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="the_project_1" name="TheProject1" | |||
uuid="THE_PROJECT_1" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
uuid="THE_PROJECT_1" root_uuid="THE_PROJECT_1" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="11" scope="FIL" qualifier="FIL" kee="the_file_1" name="TheFile1" | |||
uuid="THE_FILE_1" module_uuid="THE_PROJECT_1" module_uuid_path=".THE_PROJECT_1." | |||
uuid="THE_FILE_1" root_uuid="THE_PROJECT_1" module_uuid="THE_PROJECT_1" module_uuid_path=".THE_PROJECT_1." | |||
path="src/main/java/TheFile.java"/> | |||
<issues id="1" | |||
@@ -39,9 +39,9 @@ | |||
<!-- Project 2 --> | |||
<projects id="100" scope="PRJ" qualifier="TRK" kee="the_project_2" name="TheProject2" | |||
uuid="THE_PROJECT_2" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
uuid="THE_PROJECT_2" root_uuid="THE_PROJECT_2" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="111" scope="FIL" qualifier="FIL" kee="the_file_2" name="TheFile2" | |||
uuid="THE_FILE_2" module_uuid="THE_PROJECT_2" module_uuid_path=".THE_PROJECT_2." | |||
uuid="THE_FILE_2" root_uuid="THE_PROJECT_2" module_uuid="THE_PROJECT_2" module_uuid_path=".THE_PROJECT_2." | |||
path="src/main/java/TheFile.java"/> | |||
<issues id="10" |
@@ -2,10 +2,10 @@ | |||
<rules tags="[null]" system_tags="[null]" id="200" name="Avoid Cycles" plugin_rule_key="AvoidCycles" | |||
plugin_config_key="[null]" plugin_name="squid"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT" path="[null]" module_uuid_path=".PROJECT."/> | |||
<projects id="11" scope="PRJ" qualifier="BRC" kee="struts-core" name="Struts Core" uuid="MODULE" path="struts-core" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="100" scope="FIL" qualifier="FIL" kee="struts:Action" name="Action" uuid="FILE" path="src/main/java/Action.java" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="101" scope="FIL" qualifier="FIL" kee="pom" name="pom.xml" uuid="ROOT_FILE" path="pom.xml" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT" root_uuid="MODULE" path="[null]" module_uuid_path=".PROJECT."/> | |||
<projects id="11" scope="PRJ" qualifier="BRC" kee="struts-core" name="Struts Core" uuid="MODULE" root_uuid="PROJECT" path="struts-core" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="100" scope="FIL" qualifier="FIL" kee="struts:Action" name="Action" uuid="FILE" root_uuid="MODULE" path="src/main/java/Action.java" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="101" scope="FIL" qualifier="FIL" kee="pom" name="pom.xml" uuid="ROOT_FILE" root_uuid="MODULE" path="pom.xml" module_uuid_path=".PROJECT.MODULE."/> | |||
<issues | |||
id="1" |
@@ -2,10 +2,10 @@ | |||
<rules tags="[null]" system_tags="[null]" id="200" name="Avoid Cycles" plugin_rule_key="AvoidCycles" | |||
plugin_config_key="[null]" plugin_name="squid"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT" path="[null]" module_uuid_path=".PROJECT."/> | |||
<projects id="11" scope="PRJ" qualifier="BRC" kee="struts-core" name="Struts Core" uuid="MODULE" path="struts-core" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="100" scope="FIL" qualifier="FIL" kee="struts:Action" name="Action" uuid="FILE" path="src/main/java/Action.java" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="101" scope="FIL" qualifier="FIL" kee="pom" name="pom.xml" uuid="ROOT_FILE" path="pom.xml" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT" root_uuid="MODULE" path="[null]" module_uuid_path=".PROJECT."/> | |||
<projects id="11" scope="PRJ" qualifier="BRC" kee="struts-core" name="Struts Core" uuid="MODULE" root_uuid="PROJECT" path="struts-core" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="100" scope="FIL" qualifier="FIL" kee="struts:Action" name="Action" uuid="FILE" root_uuid="MODULE" path="src/main/java/Action.java" module_uuid_path=".PROJECT.MODULE."/> | |||
<projects id="101" scope="FIL" qualifier="FIL" kee="pom" name="pom.xml" uuid="ROOT_FILE" root_uuid="MODULE" path="pom.xml" module_uuid_path=".PROJECT.MODULE."/> | |||
<issues | |||
id="1" |
@@ -4,9 +4,9 @@ | |||
<!-- Project 1 --> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="the_project_1" name="TheProject1" | |||
uuid="THE_PROJECT_1" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
uuid="THE_PROJECT_1" root_uuid="THE_PROJECT_1" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="11" scope="FIL" qualifier="FIL" kee="the_file_1" name="TheFile1" | |||
uuid="THE_FILE_1" module_uuid="THE_PROJECT_1" module_uuid_path=".THE_PROJECT_1." | |||
uuid="THE_FILE_1" root_uuid="THE_PROJECT_1" module_uuid="THE_PROJECT_1" module_uuid_path=".THE_PROJECT_1." | |||
path="src/main/java/TheFile.java"/> | |||
<issues id="1" | |||
@@ -67,9 +67,9 @@ | |||
<!-- Project 2 --> | |||
<projects id="100" scope="PRJ" qualifier="TRK" kee="the_project_2" name="TheProject2" | |||
uuid="THE_PROJECT_2" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
uuid="THE_PROJECT_2" root_uuid="THE_PROJECT_2" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="111" scope="FIL" qualifier="FIL" kee="the_file_2" name="TheFile2" | |||
uuid="THE_FILE_2" module_uuid="THE_PROJECT_2" module_uuid_path=".THE_PROJECT_2." | |||
uuid="THE_FILE_2" root_uuid="THE_PROJECT_2" module_uuid="THE_PROJECT_2" module_uuid_path=".THE_PROJECT_2." | |||
path="src/main/java/TheFile.java"/> | |||
<issues id="10" |
@@ -2,10 +2,10 @@ | |||
<rules tags="[null]" system_tags="[null]" id="200" name="Avoid Cycles" plugin_rule_key="AvoidCycles" | |||
plugin_config_key="[null]" plugin_name="squid"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT1" path="[null]" module_uuid_path=".PROJECT1."/> | |||
<projects id="50" scope="PRJ" qualifier="BRC" kee="struts:struts-tiles" name="Struts Tiles" uuid="MODULE1" path="[null]" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="70" scope="DIR" qualifier="DIR" kee="struts:struts-tiles:/" name="src/main/java/" uuid="DIR1" path="src/main/java" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="FILE1" path="src/main/java/Action.java" module_uuid_path=".PROJECT1."/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT1" root_uuid="PROJECT1" path="[null]" module_uuid_path=".PROJECT1."/> | |||
<projects id="50" scope="PRJ" qualifier="BRC" kee="struts:struts-tiles" name="Struts Tiles" uuid="MODULE1" root_uuid="PROJECT1" path="[null]" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="70" scope="DIR" qualifier="DIR" kee="struts:struts-tiles:/" name="src/main/java/" uuid="DIR1" root_uuid="MODULE1" path="src/main/java" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="FILE1" root_uuid="MODULE1" path="src/main/java/Action.java" module_uuid_path=".PROJECT1."/> | |||
<issues | |||
id="1" |
@@ -2,10 +2,10 @@ | |||
<rules tags="[null]" system_tags="[null]" id="200" name="Avoid Cycles" plugin_rule_key="AvoidCycles" | |||
plugin_config_key="[null]" plugin_name="squid"/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT1" path="[null]" module_uuid_path=".PROJECT1."/> | |||
<projects id="50" scope="PRJ" qualifier="BRC" kee="struts:struts-tiles" name="Struts Tiles" uuid="MODULE1" path="[null]" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="70" scope="DIR" qualifier="DIR" kee="struts:struts-tiles:/" name="src/main/java/" uuid="DIR1" path="src/main/java" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="FILE1" path="src/main/java/Action.java" module_uuid_path=".PROJECT1."/> | |||
<projects id="10" scope="PRJ" qualifier="TRK" kee="struts" name="Struts" uuid="PROJECT1" root_uuid="PROJECT1" path="[null]" module_uuid_path=".PROJECT1."/> | |||
<projects id="50" scope="PRJ" qualifier="BRC" kee="struts:struts-tiles" name="Struts Tiles" uuid="MODULE1" root_uuid="PROJECT1" path="[null]" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="70" scope="DIR" qualifier="DIR" kee="struts:struts-tiles:/" name="src/main/java/" uuid="DIR1" root_uuid="MODULE1" path="src/main/java" module_uuid_path=".PROJECT1.MODULE1."/> | |||
<projects id="100" scope="FIL" qualifier="CLA" kee="struts:Action" name="Action" uuid="FILE1" root_uuid="MODULE1" path="src/main/java/Action.java" module_uuid_path=".PROJECT1."/> | |||
<issues | |||
id="1" |
@@ -2,24 +2,24 @@ | |||
<!-- java project --> | |||
<projects kee="java_project:org.sonar.bar" long_name="org.sonar.bar" scope="FIL" qualifier="CLA" name="org.sonar.bar" | |||
id="1" root_id="[null]" uuid="ABCD" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" | |||
id="1" root_uuid="ABCD" uuid="ABCD" | |||
description="[null]" enabled="[true]" language="[null]" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<projects kee="java_project:org.sonar.foo" scope="FIL" qualifier="CLA" long_name="org.sonar.foo" name="org.sonar.foo" | |||
id="2" root_id="1" uuid="BCDE" | |||
description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" | |||
id="2" root_uuid="ABCD" uuid="BCDE" | |||
description="[null]" enabled="[true]" language="java" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<projects kee="java project:org.sonar.foo.Big" scope="FIL" qualifier="CLA" long_name="org.sonar.foo.Big" | |||
name="Big" | |||
id="3" root_id="1" uuid="CDEF" | |||
description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" | |||
id="3" root_uuid="ABCD" uuid="CDEF" | |||
description="[null]" enabled="[true]" language="java" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<projects kee="java project:org.sonar.foo.Tiny" scope="FIL" qualifier="CLA" long_name="org.sonar.foo.Tiny" name="Tiny" | |||
id="4" root_id="1" uuid="DEFG" | |||
description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" | |||
id="4" root_uuid="ABCD" uuid="DEFG" | |||
description="[null]" enabled="[true]" language="java" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<snapshots id="101" component_uuid="ABCD" root_component_uuid="ABCD" root_snapshot_id="[null]" parent_snapshot_id="[null]" |
@@ -5,10 +5,11 @@ | |||
delete_historical_data="[null]"/> | |||
<projects kee="java_project" long_name="Java project" scope="PRJ" qualifier="TRK" name="Java project" | |||
id="1" root_id="[null]" uuid="ABCD" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]"/> | |||
id="1" root_uuid="UUID_JAVA_PROJECT" uuid="UUID_JAVA_PROJECT" | |||
description="[null]" enabled="[true]" language="[null]" /> | |||
<snapshots id="101" component_uuid="ABCD" root_component_uuid="ABCD" root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
<snapshots id="101" component_uuid="UUID_JAVA_PROJECT" root_component_uuid="UUID_JAVA_PROJECT" | |||
root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
scope="PRJ" qualifier="TRK" path="" depth="0" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" |
@@ -5,10 +5,11 @@ | |||
delete_historical_data="[null]"/> | |||
<projects kee="java_project" long_name="Java project" scope="PRJ" qualifier="TRK" name="Java project" | |||
id="1" root_id="[null]" uuid="ABCD" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]"/> | |||
id="1" root_uuid="UUID_JAVA_PROJECT" uuid="UUID_JAVA_PROJECT" | |||
description="[null]" enabled="[true]" language="[null]"/> | |||
<snapshots id="101" component_uuid="ABCD" root_component_uuid="ABCD" root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
<snapshots id="101" component_uuid="UUID_JAVA_PROJECT" root_component_uuid="UUID_JAVA_PROJECT" | |||
root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
scope="PRJ" qualifier="TRK" path="" depth="0" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" |
@@ -24,27 +24,28 @@ | |||
<!-- java project --> | |||
<projects kee="java_project" long_name="Java project" scope="PRJ" qualifier="TRK" name="Java project" | |||
id="1" root_id="[null]" uuid="ABCD" project_uuid="ABCD" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" | |||
id="1" root_uuid="UUID_JAVA_PROJECT" uuid="UUID_JAVA_PROJECT" project_uuid="UUID_JAVA_PROJECT" | |||
description="[null]" enabled="[true]" language="[null]" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<projects kee="java_project:org.sonar.foo" scope="DIR" qualifier="PAC" long_name="org.sonar.foo" name="org.sonar.foo" | |||
id="2" root_id="1" uuid="BCDE" project_uuid="ABCD" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" | |||
id="2" root_uuid="UUID_JAVA_PROJECT" uuid="BCDE" project_uuid="UUID_JAVA_PROJECT" | |||
description="[null]" enabled="[true]" language="[null]" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<projects kee="java_project:org.sonar.foo.Big" scope="FIL" qualifier="CLA" long_name="org.sonar.foo.Big" | |||
name="Big" | |||
id="3" root_id="1" uuid="CDEF" project_uuid="ABCD" | |||
description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" | |||
id="3" root_uuid="UUID_JAVA_PROJECT" uuid="CDEF" project_uuid="UUID_JAVA_PROJECT" | |||
description="[null]" enabled="[true]" language="java" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<projects kee="java_project:org.sonar.foo.Tiny" scope="FIL" qualifier="CLA" long_name="org.sonar.foo.Tiny" name="Tiny" | |||
id="4" root_id="1" uuid="DEFG" project_uuid="ABCD" | |||
description="[null]" enabled="[true]" language="java" copy_resource_id="[null]" person_id="[null]" | |||
id="4" root_uuid="UUID_JAVA_PROJECT" uuid="DEFG" project_uuid="UUID_JAVA_PROJECT" | |||
description="[null]" enabled="[true]" language="java" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<snapshots id="101" component_uuid="ABCD" root_component_uuid="ABCD" root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
<snapshots id="101" component_uuid="UUID_JAVA_PROJECT" root_component_uuid="UUID_JAVA_PROJECT" | |||
root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
scope="PRJ" qualifier="TRK" path="" depth="0" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" | |||
@@ -53,7 +54,8 @@ | |||
created_at="1229727600000" build_date="1229727600000" | |||
version="1.0" status="P" islast="[true]"/> | |||
<snapshots id="102" component_uuid="BCDE" root_component_uuid="ABCD" root_snapshot_id="101" parent_snapshot_id="101" | |||
<snapshots id="102" component_uuid="BCDE" root_component_uuid="UUID_JAVA_PROJECT" root_snapshot_id="101" | |||
parent_snapshot_id="101" | |||
scope="DIR" qualifier="PAC" path="101." depth="1" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" | |||
@@ -62,7 +64,8 @@ | |||
created_at="1229727600000" build_date="1229727600000" | |||
version="1.0" status="P" islast="[true]"/> | |||
<snapshots id="103" component_uuid="CDEF" root_component_uuid="ABCD" root_snapshot_id="101" parent_snapshot_id="102" | |||
<snapshots id="103" component_uuid="CDEF" root_component_uuid="UUID_JAVA_PROJECT" root_snapshot_id="101" | |||
parent_snapshot_id="102" | |||
scope="FIL" qualifier="CLA" path="101.102." depth="2" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" | |||
@@ -71,7 +74,8 @@ | |||
created_at="1229727600000" build_date="1229727600000" | |||
version="1.0" status="P" islast="[true]"/> | |||
<snapshots id="104" component_uuid="DEFG" root_component_uuid="ABCD" root_snapshot_id="101" parent_snapshot_id="102" | |||
<snapshots id="104" component_uuid="DEFG" root_component_uuid="UUID_JAVA_PROJECT" root_snapshot_id="101" | |||
parent_snapshot_id="102" | |||
scope="FIL" qualifier="CLA" path="101.102." depth="2" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" | |||
@@ -133,12 +137,13 @@ | |||
<!-- php project --> | |||
<projects kee="php_project" long_name="PHP project" scope="PRJ" qualifier="TRK" name="PHP project" | |||
id="10" root_id="[null]" uuid="EFGH" project_uuid="EFGH" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" | |||
id="10" root_uuid="UUID_JAVA_PROJECT" uuid="UUID_PHP_PROJECT" project_uuid="UUID_PHP_PROJECT" | |||
description="[null]" enabled="[true]" language="[null]" | |||
created_at="2012-12-12 04:06:00.00"/> | |||
<snapshots id="110" component_uuid="EFGH" root_component_uuid="EFGH" root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
<snapshots id="110" component_uuid="UUID_PHP_PROJECT" root_component_uuid="UUID_PHP_PROJECT" root_snapshot_id="[null]" | |||
parent_snapshot_id="[null]" | |||
scope="PRJ" qualifier="TRK" path="" depth="0" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" | |||
@@ -165,15 +170,23 @@ | |||
alert_status="[null]" description="[null]"/> | |||
<resource_index id="1" kee="java project" position="0" name_size="12" component_uuid="ABCD" root_component_uuid="ABCD" qualifier="TRK"/> | |||
<resource_index id="2" kee="java projec" position="1" name_size="12" component_uuid="ABCD" root_component_uuid="ABCD" qualifier="TRK"/> | |||
<resource_index id="3" kee="java proje" position="2" name_size="12" component_uuid="ABCD" root_component_uuid="ABCD" qualifier="TRK"/> | |||
<resource_index id="4" kee="java proj" position="3" name_size="12" component_uuid="ABCD" root_component_uuid="ABCD" qualifier="TRK"/> | |||
<resource_index id="1" kee="java project" position="0" name_size="12" component_uuid="UUID_JAVA_PROJECT" | |||
root_component_uuid="UUID_JAVA_PROJECT" qualifier="TRK"/> | |||
<resource_index id="2" kee="java projec" position="1" name_size="12" component_uuid="UUID_JAVA_PROJECT" | |||
root_component_uuid="UUID_JAVA_PROJECT" qualifier="TRK"/> | |||
<resource_index id="3" kee="java proje" position="2" name_size="12" component_uuid="UUID_JAVA_PROJECT" | |||
root_component_uuid="UUID_JAVA_PROJECT" qualifier="TRK"/> | |||
<resource_index id="4" kee="java proj" position="3" name_size="12" component_uuid="UUID_JAVA_PROJECT" | |||
root_component_uuid="UUID_JAVA_PROJECT" qualifier="TRK"/> | |||
<!-- etc --> | |||
<resource_index id="5" kee="php project" position="0" name_size="11" component_uuid="EFGH" root_component_uuid="EFGH" qualifier="TRK"/> | |||
<resource_index id="6" kee="php projec" position="1" name_size="11" component_uuid="EFGH" root_component_uuid="EFGH" qualifier="TRK"/> | |||
<resource_index id="7" kee="php proje" position="2" name_size="11" component_uuid="EFGH" root_component_uuid="EFGH" qualifier="TRK"/> | |||
<resource_index id="8" kee="php proj" position="3" name_size="11" component_uuid="EFGH" root_component_uuid="EFGH" qualifier="TRK"/> | |||
<resource_index id="5" kee="php project" position="0" name_size="11" component_uuid="UUID_PHP_PROJECT" | |||
root_component_uuid="UUID_PHP_PROJECT" qualifier="TRK"/> | |||
<resource_index id="6" kee="php projec" position="1" name_size="11" component_uuid="UUID_PHP_PROJECT" | |||
root_component_uuid="UUID_PHP_PROJECT" qualifier="TRK"/> | |||
<resource_index id="7" kee="php proje" position="2" name_size="11" component_uuid="UUID_PHP_PROJECT" | |||
root_component_uuid="UUID_PHP_PROJECT" qualifier="TRK"/> | |||
<resource_index id="8" kee="php proj" position="3" name_size="11" component_uuid="UUID_PHP_PROJECT" | |||
root_component_uuid="UUID_PHP_PROJECT" qualifier="TRK"/> | |||
<!-- etc --> | |||
@@ -7,11 +7,12 @@ | |||
<!-- java project --> | |||
<projects kee="java_project" long_name="Java project" scope="PRJ" qualifier="TRK" name="Java project" | |||
id="1" root_id="[null]" uuid="ABCD" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" | |||
id="1" root_uuid="UUID_JAVA_PROJECT" uuid="UUID_JAVA_PROJECT" | |||
description="[null]" enabled="[true]" language="[null]" | |||
created_at="2008-12-19 00:00:00.00"/> | |||
<snapshots id="101" component_uuid="ABCD" root_component_uuid="ABCD" root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
<snapshots id="101" component_uuid="UUID_JAVA_PROJECT" root_component_uuid="UUID_JAVA_PROJECT" | |||
root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
scope="PRJ" qualifier="TRK" path="" depth="0" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" | |||
@@ -32,12 +33,13 @@ | |||
<!-- php project --> | |||
<projects kee="php_project" long_name="PHP project" scope="PRJ" qualifier="TRK" name="PHP project" | |||
id="10" root_id="[null]" uuid="BCDE" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" | |||
id="10" root_uuid="UUID_PHP_PROJECT" uuid="UUID_PHP_PROJECT" | |||
description="[null]" enabled="[true]" language="[null]" | |||
created_at="2012-12-12 04:06:00.00"/> | |||
<snapshots id="110" component_uuid="BCDE" root_component_uuid="BCDE" root_snapshot_id="[null]" parent_snapshot_id="[null]" | |||
<snapshots id="110" component_uuid="UUID_PHP_PROJECT" root_component_uuid="UUID_PHP_PROJECT" root_snapshot_id="[null]" | |||
parent_snapshot_id="[null]" | |||
scope="PRJ" qualifier="TRK" path="" depth="0" | |||
purge_status="[null]" period1_mode="[null]" period1_param="[null]" period1_date="[null]" | |||
period2_mode="[null]" period2_param="[null]" period2_date="[null]" period3_mode="[null]" | |||
@@ -57,8 +59,8 @@ | |||
<!-- js project --> | |||
<projects kee="js_project" long_name="JS project" scope="PRJ" qualifier="TRK" name="JS project" | |||
id="20" root_id="[null]" uuid="CDEF" | |||
description="[null]" enabled="[true]" language="[null]" copy_resource_id="[null]" person_id="[null]" | |||
id="20" root_uuid="CDEF" uuid="CDEF" | |||
description="[null]" enabled="[true]" language="[null]" | |||
created_at="2012-12-12 04:06:00.00"/> | |||
@@ -1,8 +1,8 @@ | |||
<dataset> | |||
<projects id="100" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_resource_id="[null]" path="[null]"/> | |||
uuid="JKLM" root_uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" path="[null]"/> | |||
<snapshots id="100" component_uuid="JKLM" parent_snapshot_id="[null]" root_component_uuid="JKLM" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" |
@@ -1,7 +1,7 @@ | |||
<dataset> | |||
<projects id="100" kee="struts" root_id="[null]" qualifier="TRK" scope="PRJ" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="101" kee="Action.java" root_id="100" qualifier="CLA" scope="PRJ" uuid="CDEF" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." | |||
<projects id="100" kee="struts" root_uuid="ABCD" qualifier="TRK" scope="PRJ" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="101" kee="Action.java" root_uuid="ABCD" qualifier="CLA" scope="PRJ" uuid="CDEF" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." | |||
path="src/main/java/Action.java"/> | |||
</dataset> |
@@ -1,7 +1,7 @@ | |||
<dataset> | |||
<projects id="100" kee="struts" root_id="[null]" qualifier="TRK" scope="PRJ" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="101" kee="Action.java" root_id="100" qualifier="CLA" scope="PRJ" uuid="CDEF" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." | |||
<projects id="100" kee="struts" root_uuid="ABCD" qualifier="TRK" scope="PRJ" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="101" kee="Action.java" root_uuid="ABCD" qualifier="CLA" scope="PRJ" uuid="CDEF" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." | |||
path="src/main/java/Action.java"/> | |||
<file_sources id="101" project_uuid="ABCD" file_uuid="CDEF" |
@@ -1,7 +1,7 @@ | |||
<dataset> | |||
<projects id="100" kee="struts" root_id="[null]" qualifier="TRK" scope="PRJ" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="101" kee="ActionTest.java" root_id="100" qualifier="CLA" scope="PRJ" uuid="CDEF" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." | |||
<projects id="100" kee="struts" root_uuid="ABCD" qualifier="TRK" scope="PRJ" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." path="[null]"/> | |||
<projects id="101" kee="ActionTest.java" root_uuid="ABCD" qualifier="CLA" scope="PRJ" uuid="CDEF" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." | |||
path="src/test/java/ActionTest.java"/> | |||
<file_sources id="100" project_uuid="ABCD" file_uuid="CDEF" |
@@ -1,14 +1,14 @@ | |||
<dataset> | |||
<!-- Simple View --> | |||
<projects id="10" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." copy_resource_id="[null]" enabled="[true]" | |||
<projects id="10" uuid="ABCD" root_uuid="ABCD" project_uuid="ABCD" module_uuid="[null]" module_uuid_path="." copy_component_uuid="[null]" enabled="[true]" | |||
kee="MASTER_PROJECT" scope="PRJ" qualifier="VW" name="All projects" path="[null]"/> | |||
<snapshots id="10" component_uuid="ABCD" parent_snapshot_id="[null]" root_component_uuid="ABCD" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
depth="[null]" scope="PRJ" qualifier="VW" created_at="1228222680000" build_date="1228222680000" | |||
version="[null]" path=""/> | |||
<projects id="110" uuid="BCDE" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." copy_resource_id="100" enabled="[true]" | |||
<projects id="110" uuid="BCDE" root_uuid="ABCD" project_uuid="ABCD" module_uuid="ABCD" module_uuid_path=".ABCD." copy_component_uuid="JKLM" enabled="[true]" | |||
kee="MASTER_PROJECTorg.struts:struts" scope="FIL" qualifier="TRK" name="Struts" path="[null]"/> | |||
<snapshots id="110" component_uuid="BCDE" parent_snapshot_id="[null]" root_component_uuid="BCDE" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
@@ -16,13 +16,13 @@ | |||
version="[null]" path=""/> | |||
<!-- View with sub view --> | |||
<projects id="11" uuid="EFGH" project_uuid="EFGH" module_uuid="[null]" module_uuid_path="." copy_resource_id="[null]" enabled="[true]" | |||
<projects id="11" uuid="EFGH" root_uuid="EFGH" project_uuid="EFGH" module_uuid="[null]" module_uuid_path="." copy_component_uuid="[null]" enabled="[true]" | |||
kee="LANGUAGE_VIEW" scope="PRJ" qualifier="VW" name="By Language" path="[null]"/> | |||
<snapshots id="11" component_uuid="EFGH" parent_snapshot_id="[null]" root_component_uuid="EFGH" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
depth="[null]" scope="PRJ" qualifier="VW" created_at="1228222680000" build_date="1228222680000" | |||
version="[null]" path=""/> | |||
<projects id="112" uuid="GHIJ" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_resource_id="101" enabled="[true]" | |||
<projects id="112" uuid="GHIJ" root_uuid="EFGH" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_component_uuid="KLMN" enabled="[true]" | |||
kee="VIEW2org.elasticsearch:elasticsearch" scope="FIL" qualifier="TRK" name="SSLR" path="[null]"/> | |||
<snapshots id="112" component_uuid="GHIJ" parent_snapshot_id="[null]" root_component_uuid="GHIJ" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
@@ -30,14 +30,14 @@ | |||
version="[null]" path=""/> | |||
<!-- Sub view --> | |||
<projects id="13" uuid="FGHI" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_resource_id="[null]" enabled="[true]" | |||
<projects id="13" uuid="FGHI" root_uuid="EFGH" project_uuid="EFGH" module_uuid="EFGH" module_uuid_path=".EFGH." copy_component_uuid="[null]" enabled="[true]" | |||
kee="JAVA_PROJECTS" scope="PRJ" qualifier="SVW" name="Java projects" path="[null]"/> | |||
<snapshots id="13" component_uuid="FGHI" parent_snapshot_id="[null]" root_component_uuid="FGHI" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
depth="[null]" scope="PRJ" qualifier="SVW" created_at="1228222680000" build_date="1228222680000" | |||
version="[null]" path=""/> | |||
<projects id="113" uuid="HIJK" project_uuid="EFGH" module_uuid="FGHI" module_uuid_path=".EFGH.FGHI." copy_resource_id="100" enabled="[true]" | |||
<projects id="113" uuid="HIJK" root_uuid="EFGH" project_uuid="EFGH" module_uuid="FGHI" module_uuid_path=".EFGH.FGHI." copy_component_uuid="JKLM" enabled="[true]" | |||
kee="VIEW2org.struts:struts" scope="FIL" qualifier="TRK" name="Struts" path="[null]"/> | |||
<snapshots id="113" component_uuid="HIJK" parent_snapshot_id="[null]" root_component_uuid="HIJK" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
@@ -45,7 +45,7 @@ | |||
version="[null]" path=""/> | |||
<!-- View without project --> | |||
<projects id="14" uuid="IJKL" project_uuid="IJKL" module_uuid="[null]" module_uuid_path="." copy_resource_id="[null]" enabled="[true]" | |||
<projects id="14" uuid="IJKL" root_uuid="IJKL" project_uuid="IJKL" module_uuid="[null]" module_uuid_path="." copy_component_uuid="[null]" enabled="[true]" | |||
kee="OTHER" scope="PRJ" qualifier="VW" name="Other projects" path="[null]"/> | |||
<snapshots id="14" component_uuid="IJKL" parent_snapshot_id="[null]" root_component_uuid="IJKL" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
@@ -55,16 +55,16 @@ | |||
<!-- Real projects --> | |||
<projects id="100" scope="PRJ" qualifier="TRK" kee="org.struts:struts" name="Struts" | |||
uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_resource_id="[null]" path="[null]"/> | |||
uuid="JKLM" root_uuid="JKLM" project_uuid="JKLM" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_component_uuid="[null]" path="[null]"/> | |||
<snapshots id="100" component_uuid="JKLM" parent_snapshot_id="[null]" root_component_uuid="JKLM" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000" | |||
version="[null]" path=""/> | |||
<projects id="101" scope="PRJ" qualifier="TRK" kee="org.elasticsearch:elasticsearch" name="Elasticsearch" | |||
uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_resource_id="[null]" path="[null]"/> | |||
uuid="KLMN" root_uuid="KLMN" project_uuid="KLMN" module_uuid="[null]" module_uuid_path="." | |||
enabled="[true]" copy_component_uuid="[null]" path="[null]"/> | |||
<snapshots id="101" component_uuid="KLMN" parent_snapshot_id="[null]" root_component_uuid="KLMN" root_snapshot_id="[null]" | |||
status="P" islast="[true]" purge_status="[null]" | |||
depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000" build_date="1228222680000" |
@@ -115,7 +115,7 @@ class Api::ProjectsController < Api::ApiController | |||
end | |||
# this is really an advanced optimization ! | |||
select_columns='id,uuid,kee,name,language,long_name,scope,qualifier,root_id' | |||
select_columns='id,uuid,kee,name,language,long_name,scope,qualifier,root_uuid' | |||
select_columns += ',description' if @show_description | |||
projects=Project.find(:all, :select => select_columns, :conditions => [conditions.join(' AND '), values], :order => 'name') |
@@ -327,7 +327,6 @@ class Api::ResourcesController < Api::ApiController | |||
json['version']=snapshot.version if snapshot.version | |||
json['branch']=resource.branch if resource.branch | |||
json['description']=resource.description if resource.description | |||
json['copy']=resource.copy_resource_id if resource.copy_resource_id | |||
if include_trends | |||
json[:p1]=snapshot.period1_mode if snapshot.period1_mode | |||
json[:p1p]=snapshot.period1_param if snapshot.period1_param | |||
@@ -402,7 +401,6 @@ class Api::ResourcesController < Api::ApiController | |||
xml.date(Api::Utils.format_datetime(snapshot.created_at)) | |||
xml.creationDate(Api::Utils.format_datetime(resource.created_at)) | |||
xml.description(resource.description) if include_descriptions && resource.description | |||
xml.copy(resource.copy_resource_id) if resource.copy_resource_id | |||
if include_trends | |||
xml.period1(snapshot.period1_mode) if snapshot.period1_mode |
@@ -85,9 +85,8 @@ class ProjectController < ApplicationController | |||
def profile | |||
require_parameters :id | |||
@project_id = Api::Utils.project_id(params[:id]) | |||
access_denied unless (is_admin?(@project_id) || has_role?(:profileadmin)) | |||
# Need to display breadcrumb | |||
@project = Project.by_key(@project_id) | |||
access_denied unless (is_admin?(@project.uuid) || has_role?(:profileadmin)) | |||
call_backend do | |||
@all_quality_profiles = Internal.quality_profiles.allProfiles().to_a | |||
@@ -118,9 +117,8 @@ class ProjectController < ApplicationController | |||
def qualitygate | |||
require_parameters :id | |||
@project_id = Api::Utils.project_id(params[:id]) | |||
access_denied unless (is_admin?(@project_id) || has_role?(:gateadmin)) | |||
# Need to display breadcrumb | |||
@project = Project.by_key(@project_id) | |||
access_denied unless (is_admin?(@project.uuid) || has_role?(:gateadmin)) | |||
call_backend do | |||
@all_quality_gates = Internal.quality_gates.list().to_a |
@@ -189,7 +189,7 @@ class MeasureFilter < ActiveRecord::Base | |||
def base_resource | |||
if criteria('base') | |||
Project.first(:conditions => ['kee=? and copy_resource_id is null and person_id is null', criteria('base')]) | |||
Project.first(:conditions => ['kee=? and copy_component_uuid is null and developer_uuid is null', criteria('base')]) | |||
end | |||
end | |||
@@ -241,9 +241,9 @@ class MeasureFilter < ActiveRecord::Base | |||
end | |||
def filter_authorized_snapshot_ids(rows, controller) | |||
project_ids = rows.map { |row| row.getResourceRootId() }.compact.uniq | |||
authorized_project_ids = controller.select_authorized(:user, project_ids) | |||
snapshot_ids = rows.map { |row| row.getSnapshotId() if authorized_project_ids.include?(row.getResourceRootId()) }.compact | |||
project_uuids = rows.map { |row| row.getRootComponentUuid() }.compact.uniq | |||
authorized_project_uuids = controller.select_authorized(:user, project_uuids) | |||
snapshot_ids = rows.map { |row| row.getSnapshotId() if authorized_project_uuids.include?(row.getRootComponentUuid()) }.compact | |||
@security_exclusions = (snapshot_ids.size<rows.size) | |||
@pagination = Api::Pagination.new | |||
@pagination.per_page=(criteria(:pageSize)||999999).to_i |
@@ -28,9 +28,9 @@ class Project < ActiveRecord::Base | |||
has_many :user_roles, :foreign_key => 'resource_id' | |||
has_many :group_roles, :foreign_key => 'resource_id' | |||
has_many :manual_measures, :foreign_key => 'component_uuid', :primary_key => 'uuid' | |||
belongs_to :root, :class_name => 'Project', :foreign_key => 'root_id' | |||
belongs_to :copy_resource, :class_name => 'Project', :foreign_key => 'copy_resource_id' | |||
belongs_to :person, :class_name => 'Project', :foreign_key => 'person_id' | |||
belongs_to :root, :class_name => 'Project', :foreign_key => 'root_uuid', :primary_key => 'uuid' | |||
belongs_to :copy_resource, :class_name => 'Project', :foreign_key => 'copy_component_uuid', :primary_key => 'uuid' | |||
belongs_to :person, :class_name => 'Project', :foreign_key => 'developer_uuid', :primary_key => 'uuid' | |||
has_many :authors, :foreign_key => 'person_id', :dependent => :delete_all | |||
has_one :index, :class_name => 'ResourceIndex', :foreign_key => 'component_uuid', :primary_key => 'uuid', :conditions => 'position=0', :select => 'kee' | |||
has_many :resource_index, :foreign_key => 'resource_id' | |||
@@ -79,7 +79,7 @@ class Project < ActiveRecord::Base | |||
def modules | |||
@modules ||= | |||
begin | |||
Project.all(:conditions => {:root_id => self.id, :scope => 'PRJ'}) | |||
Project.all(:conditions => ['root_uuid=? and uuid <> ? and scope=?', self.uuid, self.uuid, 'PRJ']) | |||
end | |||
end | |||
@@ -178,16 +178,16 @@ class Project < ActiveRecord::Base | |||
nil | |||
end | |||
def resource_id_for_authorization | |||
def component_uuid_for_authorization | |||
if library? | |||
# no security on libraries | |||
nil | |||
elsif set? | |||
self.root_id || self.id | |||
self.root_uuid || self.uuid | |||
elsif last_snapshot | |||
last_snapshot.resource_id_for_authorization | |||
last_snapshot.component_uuid_for_authorization | |||
else | |||
nil | |||
self.root_uuid | |||
end | |||
end | |||
@@ -217,7 +217,7 @@ class Project < ActiveRecord::Base | |||
end | |||
def parent_module(current_module) | |||
current_module.root ? parent_module(current_module.root) : current_module | |||
current_module.root.uuid = current_module.uuid ? current_module : parent_module(current_module.root) | |||
end | |||
end |
@@ -26,9 +26,8 @@ class ResourceIndex < ActiveRecord::Base | |||
MIN_SEARCH_SIZE=2 | |||
def resource_id_for_authorization | |||
# FIXME this generates a join for every resource | |||
root_project.id | |||
def component_uuid_for_authorization | |||
root_component_uuid | |||
end | |||
end |
@@ -216,8 +216,8 @@ class Snapshot < ActiveRecord::Base | |||
(period1_mode || period2_mode || period3_mode || period4_mode || period5_mode) != nil | |||
end | |||
def resource_id_for_authorization | |||
root_project.id | |||
def component_uuid_for_authorization | |||
root_component_uuid | |||
end | |||
def path_name |
@@ -25,16 +25,16 @@ class DefaultAuthorizer | |||
global_roles(user).include?(role) | |||
end | |||
def has_role_for_resources?(user, role, resource_ids) | |||
return [] if resource_ids.empty? | |||
def has_role_for_resources?(user, role, component_uuids) | |||
return [] if component_uuids.empty? | |||
compacted_resource_ids=resource_ids.compact | |||
compacted_component_uuids=component_uuids.compact | |||
group_ids=user.groups.map(&:id) | |||
# Oracle is limited to 1000 elements in clause "IN" | |||
page_size=999 | |||
page_count=(compacted_resource_ids.size/page_size) | |||
page_count+=1 if (compacted_resource_ids.size % page_size)>0 | |||
page_count=(compacted_component_uuids.size/page_size) | |||
page_count+=1 if (compacted_component_uuids.size % page_size)>0 | |||
sanitized_role = ActiveRecord::Base.connection.quote_string(role.to_s) | |||
@@ -42,9 +42,9 @@ class DefaultAuthorizer | |||
if group_ids.empty? | |||
# Some databases do not support empty IN | |||
page_count.times do |page_index| | |||
page_rids=compacted_resource_ids[page_index*page_size...(page_index+1)*page_size] | |||
page_component_uuids=compacted_component_uuids[page_index*page_size...(page_index+1)*page_size] | |||
group_roles.concat( | |||
ActiveRecord::Base.connection.execute("SELECT resource_id FROM group_roles WHERE role='#{sanitized_role}' and group_id is null and resource_id in (#{page_rids.join(',')})") | |||
ActiveRecord::Base.connection.execute("SELECT p.uuid FROM group_roles gr INNER JOIN projects p ON p.id=gr.resource_id WHERE gr.role='#{sanitized_role}' and gr.group_id is null and p.uuid in (#{page_component_uuids.map{ |u| "'#{u}'" }.join(',')})") | |||
) | |||
end | |||
else | |||
@@ -53,11 +53,11 @@ class DefaultAuthorizer | |||
gr_page_count+=1 if (compacted_group_ids.size % page_size)>0 | |||
page_count.times do |page_index| | |||
page_rids=compacted_resource_ids[page_index*page_size...(page_index+1)*page_size] | |||
page_component_uuids=compacted_component_uuids[page_index*page_size...(page_index+1)*page_size] | |||
gr_page_count.times do |gr_page_index| | |||
page_grids=compacted_group_ids[gr_page_index*page_size...(gr_page_index+1)*page_size] | |||
group_roles.concat( | |||
ActiveRecord::Base.connection.execute("SELECT resource_id FROM group_roles WHERE role='#{sanitized_role}' and (group_id is null or group_id in(#{page_grids.join(',')})) and resource_id in (#{page_rids.join(',')})") | |||
ActiveRecord::Base.connection.execute("SELECT p.uuid FROM group_roles gr INNER JOIN projects p ON p.id=gr.resource_id WHERE gr.role='#{sanitized_role}' and (gr.group_id is null or gr.group_id in(#{page_grids.join(',')})) and p.uuid in (#{page_component_uuids.map{ |u| "'#{u}'" }.join(',')})") | |||
) | |||
end | |||
end | |||
@@ -66,21 +66,21 @@ class DefaultAuthorizer | |||
user_roles=[] | |||
if user.id | |||
page_count.times do |page_index| | |||
page_rids=compacted_resource_ids[page_index*page_size...(page_index+1)*page_size] | |||
page_component_uuids=compacted_component_uuids[page_index*page_size...(page_index+1)*page_size] | |||
user_roles.concat( | |||
ActiveRecord::Base.connection.execute("SELECT resource_id FROM user_roles WHERE role='#{sanitized_role}' and user_id=#{user.id} and resource_id in (#{page_rids.join(',')})") | |||
ActiveRecord::Base.connection.execute("SELECT p.uuid FROM user_roles ur INNER JOIN projects p ON p.id=ur.resource_id WHERE ur.role='#{sanitized_role}' and ur.user_id=#{user.id} and p.uuid in (#{page_component_uuids.map{ |u| "'#{u}'" }.join(',')})") | |||
) | |||
end | |||
end | |||
authorized_resource_ids={} | |||
authorized_component_uuids={} | |||
(group_roles.concat(user_roles)).each do |x| | |||
authorized_resource_ids[x['resource_id'].to_i]=true | |||
authorized_component_uuids[x['uuid']]=true | |||
end | |||
result=Array.new(resource_ids.size) | |||
resource_ids.each_with_index do |rid,index| | |||
result[index]=((authorized_resource_ids[rid]) || false) | |||
result=Array.new(component_uuids.size) | |||
component_uuids.each_with_index do |uuid,index| | |||
result[index]=((authorized_component_uuids[uuid]) || false) | |||
end | |||
result | |||
end |
@@ -75,21 +75,21 @@ module NeedAuthorization | |||
def has_role_for_resources?(role, objects) | |||
return [] if objects.nil? || objects.size==0 | |||
resource_ids=[] | |||
component_uuids=[] | |||
objects.each do |obj| | |||
resource_ids<<to_resource_id(obj) | |||
component_uuids<<to_component_uuid(obj) | |||
end | |||
compacted_resource_ids=resource_ids.compact.uniq | |||
compacted_booleans=AuthorizerFactory.authorizer.has_role_for_resources?(self, role.to_sym, compacted_resource_ids) | |||
boolean_per_resource_id={} | |||
compacted_resource_ids.each_with_index do |rid, index| | |||
boolean_per_resource_id[rid]=compacted_booleans[index] | |||
compacted_component_uuids=component_uuids.compact.uniq | |||
compacted_booleans=AuthorizerFactory.authorizer.has_role_for_resources?(self, role.to_sym, compacted_component_uuids) | |||
boolean_per_component_uuid={} | |||
compacted_component_uuids.each_with_index do |uuid, index| | |||
boolean_per_component_uuid[uuid]=compacted_booleans[index] | |||
end | |||
result=Array.new(resource_ids.size) | |||
resource_ids.each_with_index do |rid, index| | |||
authorized=boolean_per_resource_id[rid] | |||
result=Array.new(component_uuids.size) | |||
component_uuids.each_with_index do |uuid, index| | |||
authorized=boolean_per_component_uuid[uuid] | |||
# security is sometimes ignored (for example on libraries), so default value is true if no id to check | |||
authorized=true if authorized.nil? | |||
@@ -106,13 +106,15 @@ module NeedAuthorization | |||
end | |||
private | |||
def to_resource_id(object) | |||
def to_component_uuid(object) | |||
if object.is_a?(Fixnum) | |||
raise 'Component ID is no more supported for checking of authorisation. UUID must be used' | |||
elsif object.is_a?(String) | |||
object | |||
elsif object.respond_to?(:resource_id_for_authorization) | |||
object.resource_id_for_authorization | |||
elsif object.respond_to?(:component_uuid_for_authorization) | |||
object.component_uuid_for_authorization | |||
else | |||
nil | |||
raise 'Specified argument with type #{object.class} can not be converted to a component uuid' | |||
end | |||
end | |||
end | |||
@@ -178,19 +180,6 @@ module NeedAuthorization | |||
result | |||
end | |||
def select_authorized(role, objects, resource_method=nil) | |||
if resource_method | |||
booleans=has_role?(role, objects.map{|obj| obj.send(resource_method)}) | |||
else | |||
booleans=has_role?(role, objects) | |||
end | |||
result=[] | |||
objects.each_with_index do |obj, index| | |||
result<<obj if booleans[index]==true | |||
end | |||
result | |||
end | |||
# | |||
# Filter method to enforce a login admin requirement. | |||
# |
@@ -42,9 +42,9 @@ public class ComponentDto implements Component { | |||
private String projectUuid; | |||
private String moduleUuid; | |||
private String moduleUuidPath; | |||
private Long parentProjectId; | |||
private Long copyResourceId; | |||
private Long developerId; | |||
private String rootUuid; | |||
private String copyComponentUuid; | |||
private String developerUuid; | |||
private String path; | |||
private String deprecatedKey; | |||
@@ -197,13 +197,12 @@ public class ComponentDto implements Component { | |||
return this; | |||
} | |||
@CheckForNull | |||
public Long parentProjectId() { | |||
return parentProjectId; | |||
public String getRootUuid() { | |||
return rootUuid; | |||
} | |||
public ComponentDto setParentProjectId(@Nullable Long parentProjectId) { | |||
this.parentProjectId = parentProjectId; | |||
public ComponentDto setRootUuid(String rootUuid) { | |||
this.rootUuid = rootUuid; | |||
return this; | |||
} | |||
@@ -216,21 +215,23 @@ public class ComponentDto implements Component { | |||
return this; | |||
} | |||
public Long getCopyResourceId() { | |||
return copyResourceId; | |||
@CheckForNull | |||
public String getCopyResourceUuid() { | |||
return copyComponentUuid; | |||
} | |||
public ComponentDto setCopyResourceId(Long copyResourceId) { | |||
this.copyResourceId = copyResourceId; | |||
public ComponentDto setCopyComponentUuid(@Nullable String copyComponentUuid) { | |||
this.copyComponentUuid = copyComponentUuid; | |||
return this; | |||
} | |||
public Long getDeveloperId() { | |||
return developerId; | |||
@CheckForNull | |||
public String getDeveloperUuid() { | |||
return developerUuid; | |||
} | |||
public ComponentDto setDeveloperId(Long developerId) { | |||
this.developerId = developerId; | |||
public ComponentDto setDeveloperUuid(@Nullable String developerUuid) { | |||
this.developerUuid = developerUuid; | |||
return this; | |||
} | |||
@@ -302,9 +303,9 @@ public class ComponentDto implements Component { | |||
.append("projectUuid", projectUuid) | |||
.append("moduleUuid", moduleUuid) | |||
.append("moduleUuidPath", moduleUuidPath) | |||
.append("parentProjectId", parentProjectId) | |||
.append("copyResourceId", copyResourceId) | |||
.append("developerId", developerId) | |||
.append("rootUuid", rootUuid) | |||
.append("copyComponentUuid", copyComponentUuid) | |||
.append("developerUuid", developerUuid) | |||
.append("path", path) | |||
.append("deprecatedKey", deprecatedKey) | |||
.append("name", name) |
@@ -46,10 +46,6 @@ public final class ComponentDtoFunctions { | |||
return ToUuid.INSTANCE; | |||
} | |||
public static Function<ComponentDto, Long> toCopyResourceId() { | |||
return ToCopyResourceId.INSTANCE; | |||
} | |||
private enum ToId implements Function<ComponentDto, Long> { | |||
INSTANCE; | |||
@@ -86,12 +82,4 @@ public final class ComponentDtoFunctions { | |||
} | |||
} | |||
private enum ToCopyResourceId implements Function<ComponentDto, Long> { | |||
INSTANCE; | |||
@Override | |||
public Long apply(ComponentDto input) { | |||
return input.getCopyResourceId(); | |||
} | |||
} | |||
} |
@@ -72,12 +72,17 @@ public class ResourceDao extends AbstractDao { | |||
public ResourceDto selectResource(String componentUuid) { | |||
SqlSession session = myBatis().openSession(false); | |||
try { | |||
return session.getMapper(ResourceMapper.class).selectResourceByUuid(componentUuid); | |||
return selectResource(componentUuid, session); | |||
} finally { | |||
MyBatis.closeQuietly(session); | |||
} | |||
} | |||
@CheckForNull | |||
private static ResourceDto selectResource(String componentUuid, SqlSession session) { | |||
return session.getMapper(ResourceMapper.class).selectResourceByUuid(componentUuid); | |||
} | |||
public ResourceDto selectResource(long projectId, SqlSession session) { | |||
return session.getMapper(ResourceMapper.class).selectResource(projectId); | |||
} | |||
@@ -112,11 +117,11 @@ public class ResourceDao extends AbstractDao { | |||
private ResourceDto getRootProjectByComponentKey(DbSession session, String componentKey) { | |||
ResourceDto component = selectResource(ResourceQuery.create().setKey(componentKey), session); | |||
if (component != null) { | |||
Long rootId = component.getRootId(); | |||
if (rootId != null) { | |||
return getParentModuleByComponentId(rootId, session); | |||
} else { | |||
String rootUuid = component.getRootUuid(); | |||
if (rootUuid.equals(component.getUuid())) { | |||
return component; | |||
} else { | |||
return getParentModuleByComponentUuid(rootUuid, session); | |||
} | |||
} | |||
return null; | |||
@@ -133,14 +138,14 @@ public class ResourceDao extends AbstractDao { | |||
} | |||
@CheckForNull | |||
private ResourceDto getParentModuleByComponentId(Long componentId, DbSession session) { | |||
ResourceDto component = selectResource(componentId, session); | |||
private static ResourceDto getParentModuleByComponentUuid(String componentUUid, DbSession session) { | |||
ResourceDto component = selectResource(componentUUid, session); | |||
if (component != null) { | |||
Long rootId = component.getRootId(); | |||
if (rootId != null) { | |||
return getParentModuleByComponentId(rootId, session); | |||
} else { | |||
String rootUuid = component.getRootUuid(); | |||
if (rootUuid.equals(component.getUuid())) { | |||
return component; | |||
} else { | |||
return getParentModuleByComponentUuid(rootUuid, session); | |||
} | |||
} | |||
return null; | |||
@@ -227,11 +232,6 @@ public class ResourceDao extends AbstractDao { | |||
return newArrayList(Iterables.transform(resourceDto, ToComponent.INSTANCE)); | |||
} | |||
public void insertUsingExistingSession(ResourceDto resourceDto, SqlSession session) { | |||
ResourceMapper resourceMapper = session.getMapper(ResourceMapper.class); | |||
resourceMapper.insert(resourceDto); | |||
} | |||
private enum ToComponent implements Function<ResourceDto, Component> { | |||
INSTANCE; | |||
@@ -20,6 +20,8 @@ | |||
package org.sonar.db.component; | |||
import java.util.Date; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import static org.sonar.db.component.ComponentValidator.checkComponentKey; | |||
import static org.sonar.db.component.ComponentValidator.checkComponentName; | |||
@@ -35,15 +37,15 @@ public class ResourceDto { | |||
private String deprecatedKey; | |||
private String name; | |||
private String longName; | |||
private Long rootId; | |||
private String rootUuid; | |||
private String path; | |||
private String scope; | |||
private String qualifier; | |||
private boolean enabled = true; | |||
private String description; | |||
private String language; | |||
private Long copyResourceId; | |||
private Long personId; | |||
private String copyComponentUuid; | |||
private String developerUuid; | |||
private Date createdAt; | |||
private Long authorizationUpdatedAt; | |||
@@ -119,12 +121,12 @@ public class ResourceDto { | |||
return this; | |||
} | |||
public Long getRootId() { | |||
return rootId; | |||
public String getRootUuid() { | |||
return rootUuid; | |||
} | |||
public ResourceDto setRootId(Long rootId) { | |||
this.rootId = rootId; | |||
public ResourceDto setRootUuid(String rootUuid) { | |||
this.rootUuid = rootUuid; | |||
return this; | |||
} | |||
@@ -191,21 +193,23 @@ public class ResourceDto { | |||
return this; | |||
} | |||
public Long getCopyResourceId() { | |||
return copyResourceId; | |||
@CheckForNull | |||
public String getCopyComponentUuid() { | |||
return copyComponentUuid; | |||
} | |||
public ResourceDto setCopyResourceId(Long copyResourceId) { | |||
this.copyResourceId = copyResourceId; | |||
public ResourceDto setCopyComponentUuid(@Nullable String copyComponentUuid) { | |||
this.copyComponentUuid = copyComponentUuid; | |||
return this; | |||
} | |||
public Long getPersonId() { | |||
return personId; | |||
@CheckForNull | |||
public String getDeveloperUuid() { | |||
return developerUuid; | |||
} | |||
public ResourceDto setPersonId(Long personId) { | |||
this.personId = personId; | |||
public ResourceDto setDeveloperUuid(@Nullable String developerUuid) { | |||
this.developerUuid = developerUuid; | |||
return this; | |||
} | |||
@@ -44,7 +44,7 @@ public class ResourceKeyUpdaterDao implements Dao { | |||
this.mybatis = mybatis; | |||
} | |||
public void updateKey(long projectId, String newKey) { | |||
public void updateKey(String projectUuid, String newKey) { | |||
DbSession session = mybatis.openSession(true); | |||
ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class); | |||
try { | |||
@@ -53,9 +53,9 @@ public class ResourceKeyUpdaterDao implements Dao { | |||
} | |||
// must SELECT first everything | |||
ResourceDto project = mapper.selectProject(projectId); | |||
ResourceDto project = mapper.selectProject(projectUuid); | |||
String projectOldKey = project.getKey(); | |||
List<ResourceDto> resources = mapper.selectProjectResources(projectId); | |||
List<ResourceDto> resources = mapper.selectProjectResources(projectUuid); | |||
resources.add(project); | |||
// and then proceed with the batch UPDATE at once | |||
@@ -67,12 +67,12 @@ public class ResourceKeyUpdaterDao implements Dao { | |||
} | |||
} | |||
public Map<String, String> checkModuleKeysBeforeRenaming(long projectId, String stringToReplace, String replacementString) { | |||
public Map<String, String> checkModuleKeysBeforeRenaming(String projectUuid, String stringToReplace, String replacementString) { | |||
SqlSession session = mybatis.openSession(false); | |||
ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class); | |||
Map<String, String> result = Maps.newHashMap(); | |||
try { | |||
Set<ResourceDto> modules = collectAllModules(projectId, stringToReplace, mapper); | |||
Set<ResourceDto> modules = collectAllModules(projectUuid, stringToReplace, mapper); | |||
for (ResourceDto module : modules) { | |||
String newKey = computeNewKey(module, stringToReplace, replacementString); | |||
if (mapper.countResourceByKey(newKey) > 0) { | |||
@@ -87,14 +87,14 @@ public class ResourceKeyUpdaterDao implements Dao { | |||
return result; | |||
} | |||
public void bulkUpdateKey(DbSession session, long projectId, String stringToReplace, String replacementString) { | |||
public void bulkUpdateKey(DbSession session, String projectUuid, String stringToReplace, String replacementString) { | |||
ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class); | |||
// must SELECT first everything | |||
Set<ResourceDto> modules = collectAllModules(projectId, stringToReplace, mapper); | |||
Set<ResourceDto> modules = collectAllModules(projectUuid, stringToReplace, mapper); | |||
checkNewNameOfAllModules(modules, stringToReplace, replacementString, mapper); | |||
Map<ResourceDto, List<ResourceDto>> allResourcesByModuleMap = Maps.newHashMap(); | |||
for (ResourceDto module : modules) { | |||
allResourcesByModuleMap.put(module, mapper.selectProjectResources(module.getId())); | |||
allResourcesByModuleMap.put(module, mapper.selectProjectResources(module.getUuid())); | |||
} | |||
// and then proceed with the batch UPDATE at once | |||
@@ -107,16 +107,6 @@ public class ResourceKeyUpdaterDao implements Dao { | |||
} | |||
} | |||
public void bulkUpdateKey(long projectId, String stringToReplace, String replacementString) { | |||
DbSession session = mybatis.openSession(true); | |||
try { | |||
bulkUpdateKey(session, projectId, stringToReplace, replacementString); | |||
session.commit(); | |||
} finally { | |||
MyBatis.closeQuietly(session); | |||
} | |||
} | |||
private static String computeNewKey(ResourceDto resource, String stringToReplace, String replacementString) { | |||
return resource.getKey().replaceAll(stringToReplace, replacementString); | |||
} | |||
@@ -135,14 +125,14 @@ public class ResourceKeyUpdaterDao implements Dao { | |||
} | |||
} | |||
private static Set<ResourceDto> collectAllModules(long projectId, String stringToReplace, ResourceKeyUpdaterMapper mapper) { | |||
ResourceDto project = mapper.selectProject(projectId); | |||
private static Set<ResourceDto> collectAllModules(String projectUuid, String stringToReplace, ResourceKeyUpdaterMapper mapper) { | |||
ResourceDto project = mapper.selectProject(projectUuid); | |||
Set<ResourceDto> modules = Sets.newHashSet(); | |||
if (project.getKey().contains(stringToReplace)) { | |||
modules.add(project); | |||
} | |||
for (ResourceDto submodule : mapper.selectDescendantProjects(projectId)) { | |||
modules.addAll(collectAllModules(submodule.getId(), stringToReplace, mapper)); | |||
for (ResourceDto submodule : mapper.selectDescendantProjects(projectUuid)) { | |||
modules.addAll(collectAllModules(submodule.getUuid(), stringToReplace, mapper)); | |||
} | |||
return modules; | |||
} |
@@ -20,6 +20,7 @@ | |||
package org.sonar.db.component; | |||
import java.util.List; | |||
import org.apache.ibatis.annotations.Param; | |||
/** | |||
* @since 3.2 | |||
@@ -28,11 +29,11 @@ public interface ResourceKeyUpdaterMapper { | |||
int countResourceByKey(String key); | |||
ResourceDto selectProject(long projectId); | |||
ResourceDto selectProject(@Param("uuid") String uuid); | |||
List<ResourceDto> selectProjectResources(long projectId); | |||
List<ResourceDto> selectProjectResources(@Param("rootUuid") String rootUuid); | |||
List<ResourceDto> selectDescendantProjects(long projectId); | |||
List<ResourceDto> selectDescendantProjects(@Param("rootUuid") String rootUuid); | |||
void update(ResourceDto resource); | |||
@@ -62,10 +62,6 @@ public interface ResourceMapper { | |||
ResourceDto selectProvisionedProject(@Param("key") String key); | |||
void insert(ResourceDto resource); | |||
void update(ResourceDto resource); | |||
void updateAuthorizationDate(@Param("projectId") Long projectId, @Param("authorizationDate") Long authorizationDate); | |||
} |
@@ -29,8 +29,6 @@ import java.util.Map; | |||
import java.util.Set; | |||
import javax.annotation.Nonnull; | |||
import javax.annotation.Nullable; | |||
import org.apache.ibatis.session.ResultHandler; | |||
import org.apache.ibatis.session.SqlSession; | |||
import org.sonar.db.Dao; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.MyBatis; | |||
@@ -47,16 +45,6 @@ public class IssueDao implements Dao { | |||
this.mybatis = mybatis; | |||
} | |||
public void selectNonClosedIssuesByModule(long componentId, ResultHandler handler) { | |||
SqlSession session = mybatis.openSession(false); | |||
try { | |||
session.select("org.sonar.db.issue.IssueMapper.selectNonClosedIssuesByModule", componentId, handler); | |||
} finally { | |||
MyBatis.closeQuietly(session); | |||
} | |||
} | |||
public Optional<IssueDto> selectByKey(DbSession session, String key) { | |||
return Optional.fromNullable(mapper(session).selectByKey(key)); | |||
} |
@@ -132,7 +132,7 @@ public class PurgeDao implements Dao { | |||
private void disableOrphanResources(final ResourceDto project, final SqlSession session, final PurgeMapper purgeMapper, final PurgeListener purgeListener) { | |||
final List<IdUuidPair> componentIdUuids = new ArrayList<>(); | |||
session.select("org.sonar.db.purge.PurgeMapper.selectComponentIdUuidsToDisable", project.getId(), | |||
session.select("org.sonar.db.purge.PurgeMapper.selectComponentIdUuidsToDisable", project.getUuid(), | |||
resultContext -> { | |||
IdUuidPair componentIdUuid = (IdUuidPair) resultContext.getResultObject(); | |||
if (componentIdUuid.getId() != null) { |
@@ -16,11 +16,11 @@ | |||
p.qualifier as qualifier, | |||
p.scope as scope, | |||
p.language as language, | |||
p.root_id as parentProjectId, | |||
p.root_uuid as rootUuid, | |||
p.path as path, | |||
p.enabled as enabled, | |||
p.copy_resource_id as copyResourceId, | |||
p.person_id as developerId, | |||
p.copy_component_uuid as copyComponentUuid, | |||
p.developer_uuid as developerUuid, | |||
p.authorization_updated_at as authorizationUpdatedAt, | |||
p.created_at as createdAt | |||
</sql> | |||
@@ -32,7 +32,7 @@ | |||
p.kee as kee, | |||
p.qualifier as qualifier, | |||
p.scope as scope, | |||
P.copy_resource_id as copyResourceId, | |||
P.copy_component_uuid as copyComponentUuid, | |||
p.module_uuid as moduleUuid | |||
</sql> | |||
@@ -151,7 +151,7 @@ | |||
SELECT | |||
<include refid="componentColumns"/> | |||
FROM projects p | |||
INNER JOIN projects child ON child.root_id=p.id AND child.enabled=${_true} | |||
INNER JOIN projects child ON child.root_uuid=p.uuid AND child.enabled=${_true} | |||
<where> | |||
AND p.enabled=${_true} | |||
AND p.scope='PRJ' | |||
@@ -248,7 +248,7 @@ | |||
from projects p | |||
<where> | |||
AND p.enabled=${_true} | |||
AND p.copy_resource_id is null | |||
AND p.copy_component_uuid is null | |||
AND p.qualifier in | |||
<foreach collection="qualifiers" open="(" close=")" item="qualifier" separator=","> | |||
#{qualifier} | |||
@@ -279,7 +279,7 @@ | |||
from projects p | |||
<where> | |||
AND p.enabled=${_true} | |||
AND p.copy_resource_id is null | |||
AND p.copy_component_uuid is null | |||
<if test="query.qualifiers!=null"> | |||
AND p.qualifier in | |||
<foreach collection="query.qualifiers" item="qualifier" open="(" close=")" separator=","> | |||
@@ -373,11 +373,10 @@ | |||
WHERE ri.kee like #{query.nameOrKeyQueryToSqlForResourceIndex} ESCAPE '/' | |||
) | |||
OR | |||
p.copy_resource_id IN ( | |||
SELECT p1.id | |||
FROM resource_index ri, projects p1 | |||
p.copy_component_uuid IN ( | |||
SELECT ri.component_uuid | |||
FROM resource_index ri | |||
WHERE ri.kee like #{query.nameOrKeyQueryToSqlForResourceIndex} ESCAPE '/' | |||
and p1.uuid = ri.component_uuid | |||
) | |||
) | |||
</if> | |||
@@ -388,7 +387,7 @@ | |||
from projects p | |||
<where> | |||
p.enabled=${_true} | |||
AND p.copy_resource_id is null | |||
AND p.copy_component_uuid is null | |||
AND p.qualifier in | |||
<foreach collection="qualifiers" open="(" close=")" item="qualifier" separator=","> | |||
#{qualifier} | |||
@@ -413,7 +412,7 @@ | |||
<select id="selectProjectsFromView" resultType="String"> | |||
SELECT p.uuid FROM projects technical_projects | |||
INNER JOIN projects p on p.id=technical_projects.copy_resource_id AND p.enabled=${_true} | |||
INNER JOIN projects p on p.uuid=technical_projects.copy_component_uuid AND p.enabled=${_true} | |||
<where> | |||
technical_projects.enabled=${_true} AND technical_projects.project_uuid=#{projectViewUuid} | |||
AND technical_projects.module_uuid_path LIKE #{viewUuidLikeQuery} | |||
@@ -454,7 +453,7 @@ | |||
s.id is null | |||
and p.enabled=${_true} | |||
and p.qualifier=#{qualifier} | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
<if test="query!=null"> | |||
and ( | |||
UPPER(p.name) like #{query} | |||
@@ -482,7 +481,7 @@ | |||
where | |||
s2.id is null | |||
and p.qualifier=#{qualifier} | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
<if test="query!=null"> | |||
and ( | |||
UPPER(p.name) like #{query} | |||
@@ -493,14 +492,14 @@ | |||
<sql id="insertSql"> | |||
INSERT INTO projects (kee, deprecated_kee, uuid, project_uuid, module_uuid, module_uuid_path, name, long_name, | |||
qualifier, scope, language, description, root_id, path, copy_resource_id, person_id, enabled, | |||
qualifier, scope, language, description, root_uuid, path, copy_component_uuid, developer_uuid, enabled, | |||
created_at, authorization_updated_at) | |||
VALUES (#{kee,jdbcType=VARCHAR}, #{deprecatedKey,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR}, | |||
#{projectUuid,jdbcType=VARCHAR}, #{moduleUuid,jdbcType=VARCHAR}, #{moduleUuidPath,jdbcType=VARCHAR}, | |||
#{name,jdbcType=VARCHAR}, #{longName,jdbcType=VARCHAR}, #{qualifier,jdbcType=VARCHAR}, #{scope,jdbcType=VARCHAR}, | |||
#{language,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, | |||
#{parentProjectId,jdbcType=BIGINT}, #{path,jdbcType=VARCHAR}, #{copyResourceId,jdbcType=BIGINT}, | |||
#{developerId,jdbcType=BIGINT}, | |||
#{rootUuid,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{copyComponentUuid,jdbcType=VARCHAR}, | |||
#{developerUuid,jdbcType=VARCHAR}, | |||
#{enabled,jdbcType=BOOLEAN}, | |||
#{createdAt,jdbcType=TIMESTAMP}, #{authorizationUpdatedAt,jdbcType=BIGINT}) | |||
</sql> | |||
@@ -526,10 +525,10 @@ | |||
scope=#{scope,jdbcType=VARCHAR}, | |||
language=#{language,jdbcType=VARCHAR}, | |||
description=#{description,jdbcType=VARCHAR}, | |||
root_id=#{parentProjectId,jdbcType=BIGINT}, | |||
root_uuid=#{rootUuid,jdbcType=VARCHAR}, | |||
path=#{path,jdbcType=VARCHAR}, | |||
copy_resource_id=#{copyResourceId,jdbcType=BIGINT}, | |||
person_id=#{developerId,jdbcType=BIGINT}, | |||
copy_component_uuid=#{copyComponentUuid,jdbcType=VARCHAR}, | |||
developer_uuid=#{developerUuid,jdbcType=VARCHAR}, | |||
enabled=#{enabled,jdbcType=BOOLEAN}, | |||
authorization_updated_at=#{authorizationUpdatedAt,jdbcType=BIGINT} | |||
WHERE uuid=#{uuid} |
@@ -5,7 +5,7 @@ | |||
<select id="selectProjectIdsFromQueryAndViewOrSubViewUuid" parameterType="map" resultType="long"> | |||
SELECT original.id FROM resource_index r | |||
INNER JOIN projects original ON r.component_uuid = original.uuid | |||
INNER JOIN projects copy ON original.id = copy.copy_resource_id | |||
INNER JOIN projects copy ON original.uuid = copy.copy_component_uuid | |||
<where> | |||
AND copy.module_uuid_path LIKE #{viewUuidQuery} | |||
AND r.kee LIKE #{query} | |||
@@ -23,7 +23,7 @@ | |||
from projects p, projects root, snapshots s | |||
<where> | |||
p.enabled=${_true} | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
and p.uuid=s.component_uuid | |||
and s.islast=${_true} | |||
<if test="scopes != null"> |
@@ -6,8 +6,9 @@ | |||
<resultMap id="resourceResultMap" type="Resource"> | |||
<id property="id" column="id"/> | |||
<result property="key" column="kee"/> | |||
<result property="uuid" column="uuid"/> | |||
<result property="deprecatedKey" column="deprecated_kee"/> | |||
<result property="rootId" column="root_id"/> | |||
<result property="rootUuid" column="root_uuid"/> | |||
<result property="scope" column="scope"/> | |||
</resultMap> | |||
@@ -17,16 +18,16 @@ | |||
WHERE kee = #{key} | |||
</select> | |||
<select id="selectProject" parameterType="long" resultMap="resourceResultMap"> | |||
select * from projects where id=#{id} | |||
<select id="selectProject" parameterType="String" resultMap="resourceResultMap"> | |||
select * from projects where uuid=#{uuid} | |||
</select> | |||
<select id="selectProjectResources" parameterType="long" resultMap="resourceResultMap"> | |||
select * from projects where root_id=#{id} AND scope!='PRJ' | |||
<select id="selectProjectResources" parameterType="String" resultMap="resourceResultMap"> | |||
select * from projects where root_uuid=#{rootUuid} AND scope!='PRJ' | |||
</select> | |||
<select id="selectDescendantProjects" parameterType="long" resultMap="resourceResultMap"> | |||
select * from projects where scope='PRJ' and root_id=#{id} | |||
<select id="selectDescendantProjects" parameterType="String" resultMap="resourceResultMap"> | |||
select * from projects where scope='PRJ' and root_uuid=#{rootUuid} and uuid!=#{rootUuid} | |||
</select> | |||
<update id="update" parameterType="Resource"> |
@@ -47,14 +47,14 @@ | |||
<result property="path" column="path"/> | |||
<result property="name" column="name"/> | |||
<result property="longName" column="long_name"/> | |||
<result property="rootId" column="root_id"/> | |||
<result property="rootUuid" column="root_uuid"/> | |||
<result property="scope" column="scope"/> | |||
<result property="qualifier" column="qualifier"/> | |||
<result property="enabled" column="enabled"/> | |||
<result property="description" column="description"/> | |||
<result property="language" column="language"/> | |||
<result property="copyResourceId" column="copy_resource_id"/> | |||
<result property="personId" column="person_id"/> | |||
<result property="copyComponentUuid" column="copy_component_uuid"/> | |||
<result property="developerUuid" column="developer_uuid"/> | |||
<result property="createdAt" column="created_at"/> | |||
<result property="authorizationUpdatedAt" column="authorization_updated_at"/> | |||
</resultMap> | |||
@@ -111,7 +111,7 @@ | |||
<select id="selectLastSnapshotByResourceKey" parameterType="string" resultMap="snapshotResultMap"> | |||
SELECT s.* FROM snapshots s | |||
INNER JOIN projects p on p.uuid=s.component_uuid AND p.enabled=${_true} AND p.copy_resource_id IS NULL | |||
INNER JOIN projects p on p.uuid=s.component_uuid AND p.enabled=${_true} AND p.copy_component_uuid is null | |||
<where> | |||
AND p.kee=#{id} | |||
AND s.islast=${_true} | |||
@@ -120,7 +120,7 @@ | |||
<select id="selectLastSnapshotByResourceUuid" parameterType="string" resultMap="snapshotResultMap"> | |||
SELECT s.* from snapshots s | |||
INNER JOIN projects p on p.uuid=s.component_uuid AND p.enabled=${_true} AND p.copy_resource_id IS NULL | |||
INNER JOIN projects p on p.uuid=s.component_uuid AND p.enabled=${_true} AND p.copy_component_uuid is null | |||
<where> | |||
AND p.uuid=#{uuid} | |||
AND s.islast=${_true} | |||
@@ -147,7 +147,7 @@ | |||
</foreach> | |||
</if> | |||
and p.enabled=${_true} | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
</where> | |||
</select> | |||
@@ -166,7 +166,7 @@ | |||
</foreach> | |||
</if> | |||
and p.enabled=${_true} | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
and s.islast=${_true} | |||
</where> | |||
</sql> | |||
@@ -183,7 +183,7 @@ | |||
p.qualifier=#{qualifier} | |||
</foreach> | |||
</if> | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
</where> | |||
</select> | |||
@@ -198,7 +198,7 @@ | |||
p.qualifier=#{qualifier} | |||
</foreach> | |||
</if> | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
</where> | |||
</select> | |||
@@ -207,33 +207,9 @@ | |||
left join snapshots s on s.component_uuid=p.uuid | |||
where s.id is null | |||
and p.kee = #{key} | |||
and p.copy_resource_id is null | |||
and p.copy_component_uuid is null | |||
</select> | |||
<insert id="insert" parameterType="Resource" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> | |||
insert into projects | |||
(uuid, project_uuid, module_uuid, module_uuid_path, name, long_name, description, scope, qualifier, kee, | |||
deprecated_kee, path, language, root_id, copy_resource_id, person_id, | |||
enabled, authorization_updated_at, created_at) | |||
values ( | |||
#{uuid,jdbcType=VARCHAR}, #{projectUuid,jdbcType=VARCHAR}, #{moduleUuid,jdbcType=VARCHAR}, | |||
#{moduleUuidPath,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, | |||
#{longName,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{scope,jdbcType=VARCHAR}, | |||
#{qualifier,jdbcType=VARCHAR}, | |||
#{key,jdbcType=VARCHAR}, #{deprecatedKey,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{language,jdbcType=VARCHAR}, | |||
#{rootId,jdbcType=INTEGER}, #{copyResourceId,jdbcType=INTEGER}, | |||
#{personId,jdbcType=INTEGER}, #{enabled,jdbcType=BOOLEAN}, #{authorizationUpdatedAt,jdbcType=BIGINT}, | |||
#{createdAt,jdbcType=TIMESTAMP} | |||
) | |||
</insert> | |||
<update id="update" parameterType="Resource"> | |||
update projects set name=#{name}, long_name=#{longName}, description=#{description}, | |||
scope=#{scope}, qualifier=#{qualifier}, kee=#{key}, deprecated_kee=#{deprecatedKey}, path=#{path}, | |||
language=#{language}, root_id=#{rootId}, copy_resource_id=#{copyResourceId}, | |||
person_id=#{personId}, enabled=#{enabled} where id=#{id} | |||
</update> | |||
<update id="updateAuthorizationDate" parameterType="map"> | |||
update projects set authorization_updated_at=#{authorizationDate} | |||
where id=#{projectId} |
@@ -162,45 +162,6 @@ | |||
i.status <> 'CLOSED' | |||
</select> | |||
<select id="selectNonClosedIssuesByModule" parameterType="long" resultType="Issue"> | |||
select | |||
i.id, | |||
i.kee as kee, | |||
i.rule_id as ruleId, | |||
i.component_uuid as componentUuid, | |||
i.project_uuid as projectUuid, | |||
i.severity as severity, | |||
i.manual_severity as manualSeverity, | |||
i.message as message, | |||
i.line as line, | |||
i.locations as locations, | |||
i.gap as gap, | |||
i.effort as effort, | |||
i.status as status, | |||
i.resolution as resolution, | |||
i.checksum as checksum, | |||
i.assignee as assignee, | |||
i.author_login as authorLogin, | |||
i.tags as tagsString, | |||
i.issue_attributes as issueAttributes, | |||
i.issue_creation_date as issueCreationTime, | |||
i.issue_update_date as issueUpdateTime, | |||
i.issue_close_date as issueCloseTime, | |||
i.created_at as createdAt, | |||
i.updated_at as updatedAt, | |||
i.issue_type as type, | |||
r.plugin_rule_key as ruleKey, | |||
r.plugin_name as ruleRepo, | |||
p.kee as componentKey, | |||
root.kee as projectKey | |||
from issues i | |||
inner join (select p.id, p.uuid,p.kee from projects p where (p.root_id=#{id} and p.qualifier <> 'BRC') or | |||
(p.id=#{id})) p on p.uuid=i.component_uuid | |||
inner join rules r on r.id=i.rule_id | |||
left outer join projects root on root.uuid=i.project_uuid | |||
where i.status <> 'CLOSED' | |||
</select> | |||
<select id="selectComponentUuidsOfOpenIssuesForProjectUuid" parameterType="string" resultType="string"> | |||
select distinct(i.component_uuid) | |||
from issues i |
@@ -72,9 +72,9 @@ | |||
not exists(select e.id from events e where e.snapshot_id=s.id) | |||
</select> | |||
<select id="selectComponentIdUuidsToDisable" resultType="org.sonar.db.purge.IdUuidPair" parameterType="long"> | |||
<select id="selectComponentIdUuidsToDisable" resultType="org.sonar.db.purge.IdUuidPair" parameterType="String"> | |||
select p.id, p.uuid from projects p | |||
where (p.id=#{id} or p.root_id=#{id}) and p.enabled=${_true} | |||
where p.root_uuid=#{uuid} and p.enabled=${_true} | |||
and not exists(select s.component_uuid from snapshots s where s.islast=${_true} and s.component_uuid=p.uuid) | |||
</select> | |||
@@ -9,7 +9,20 @@ | |||
WHERE | |||
gr.role=#{role} | |||
and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId})) | |||
and (gr.resource_id = p.root_id or gr.resource_id = p.id) and | |||
and gr.resource_id = p.id | |||
and | |||
<foreach collection="componentKeys" open="(" close=")" item="element" index="index" separator=" or "> | |||
p.kee=#{element} | |||
</foreach> | |||
UNION | |||
SELECT p.kee | |||
FROM group_roles gr, projects root, projects p | |||
WHERE | |||
gr.role=#{role} | |||
and (gr.group_id is null or gr.group_id in (select gu.group_id from groups_users gu where gu.user_id=#{userId})) | |||
and gr.resource_id = root.id | |||
and p.root_uuid = root.uuid | |||
and | |||
<foreach collection="componentKeys" open="(" close=")" item="element" index="index" separator=" or "> | |||
p.kee=#{element} | |||
</foreach> | |||
@@ -19,7 +32,8 @@ | |||
INNER JOIN projects p on p.id = ur.resource_id | |||
WHERE | |||
ur.role=#{role} | |||
and ur.user_id=#{userId} and | |||
and ur.user_id=#{userId} | |||
and | |||
<foreach collection="componentKeys" open="(" close=")" item="element" index="index" separator=" or "> | |||
p.kee=#{element} | |||
</foreach> | |||
@@ -31,7 +45,20 @@ | |||
WHERE | |||
gr.role=#{role} | |||
and gr.group_id is null | |||
and (gr.resource_id = p.root_id or gr.resource_id = p.id) and | |||
and gr.resource_id = p.id | |||
and | |||
<foreach collection="componentKeys" open="(" close=")" item="element" index="index" separator=" or "> | |||
p.kee=#{element} | |||
</foreach> | |||
UNION | |||
SELECT p.kee | |||
FROM group_roles gr, projects root, projects p | |||
WHERE | |||
gr.role=#{role} | |||
and gr.group_id is null | |||
and gr.resource_id = root.id | |||
and p.root_uuid = root.uuid | |||
and | |||
<foreach collection="componentKeys" open="(" close=")" item="element" index="index" separator=" or "> | |||
p.kee=#{element} | |||
</foreach> |
@@ -68,7 +68,7 @@ public class ComponentDaoTest { | |||
assertThat(result.uuid()).isEqualTo("KLMN"); | |||
assertThat(result.moduleUuid()).isEqualTo("EFGH"); | |||
assertThat(result.moduleUuidPath()).isEqualTo(".ABCD.EFGH."); | |||
assertThat(result.parentProjectId()).isEqualTo(2); | |||
assertThat(result.getRootUuid()).isEqualTo("EFGH"); | |||
assertThat(result.projectUuid()).isEqualTo("ABCD"); | |||
assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java"); | |||
assertThat(result.path()).isEqualTo("src/org/struts/RequestContext.java"); | |||
@@ -77,7 +77,8 @@ public class ComponentDaoTest { | |||
assertThat(result.qualifier()).isEqualTo("FIL"); | |||
assertThat(result.scope()).isEqualTo("FIL"); | |||
assertThat(result.language()).isEqualTo("java"); | |||
assertThat(result.getCopyResourceId()).isNull(); | |||
assertThat(result.getCopyResourceUuid()).isNull(); | |||
assertThat(result.getDeveloperUuid()).isNull(); | |||
assertThat(underTest.selectByUuid(dbSession, "UNKNOWN")).isAbsent(); | |||
} | |||
@@ -91,7 +92,7 @@ public class ComponentDaoTest { | |||
assertThat(result.uuid()).isEqualTo("STUV"); | |||
assertThat(result.moduleUuid()).isEqualTo("OPQR"); | |||
assertThat(result.moduleUuidPath()).isEqualTo(".OPQR."); | |||
assertThat(result.parentProjectId()).isEqualTo(11); | |||
assertThat(result.getRootUuid()).isEqualTo("OPQR"); | |||
assertThat(result.projectUuid()).isEqualTo("OPQR"); | |||
assertThat(result.key()).isEqualTo("DEV:anakin@skywalker.name:org.struts:struts"); | |||
assertThat(result.path()).isNull(); | |||
@@ -100,7 +101,8 @@ public class ComponentDaoTest { | |||
assertThat(result.qualifier()).isEqualTo("DEV_PRJ"); | |||
assertThat(result.scope()).isEqualTo("PRJ"); | |||
assertThat(result.language()).isNull(); | |||
assertThat(result.getCopyResourceId()).isEqualTo(1L); | |||
assertThat(result.getCopyResourceUuid()).isEqualTo("ABCD"); | |||
assertThat(result.getDeveloperUuid()).isEqualTo("OPQR"); | |||
} | |||
@Test | |||
@@ -108,7 +110,7 @@ public class ComponentDaoTest { | |||
db.prepareDbUnit(getClass(), "shared.xml"); | |||
ComponentDto result = underTest.selectByUuid(dbSession, "STUV").get(); | |||
assertThat(result.getDeveloperId()).isEqualTo(11L); | |||
assertThat(result.getDeveloperUuid()).isEqualTo("OPQR"); | |||
} | |||
@Test | |||
@@ -144,7 +146,8 @@ public class ComponentDaoTest { | |||
assertThat(result.qualifier()).isEqualTo("FIL"); | |||
assertThat(result.scope()).isEqualTo("FIL"); | |||
assertThat(result.language()).isEqualTo("java"); | |||
assertThat(result.parentProjectId()).isEqualTo(2); | |||
assertThat(result.uuid()).isEqualTo("KLMN"); | |||
assertThat(result.getRootUuid()).isEqualTo("EFGH"); | |||
assertThat(underTest.selectByKey(dbSession, "unknown")).isAbsent(); | |||
} | |||
@@ -180,7 +183,7 @@ public class ComponentDaoTest { | |||
assertThat(result.qualifier()).isEqualTo("TRK"); | |||
assertThat(result.scope()).isEqualTo("PRJ"); | |||
assertThat(result.language()).isNull(); | |||
assertThat(result.parentProjectId()).isNull(); | |||
assertThat(result.getRootUuid()).isEqualTo("ABCD"); | |||
assertThat(result.getAuthorizationUpdatedAt()).isEqualTo(123456789L); | |||
} | |||
@@ -200,7 +203,7 @@ public class ComponentDaoTest { | |||
assertThat(result.qualifier()).isEqualTo("FIL"); | |||
assertThat(result.scope()).isEqualTo("FIL"); | |||
assertThat(result.language()).isEqualTo("java"); | |||
assertThat(result.parentProjectId()).isEqualTo(2); | |||
assertThat(result.getRootUuid()).isEqualTo("EFGH"); | |||
assertThat(underTest.selectByKeys(dbSession, singletonList("unknown"))).isEmpty(); | |||
} | |||
@@ -221,7 +224,7 @@ public class ComponentDaoTest { | |||
assertThat(result.qualifier()).isEqualTo("FIL"); | |||
assertThat(result.scope()).isEqualTo("FIL"); | |||
assertThat(result.language()).isEqualTo("java"); | |||
assertThat(result.parentProjectId()).isEqualTo(2); | |||
assertThat(result.getRootUuid()).isEqualTo("EFGH"); | |||
assertThat(underTest.selectByIds(dbSession, newArrayList(555L))).isEmpty(); | |||
} | |||
@@ -238,7 +241,7 @@ public class ComponentDaoTest { | |||
assertThat(result.uuid()).isEqualTo("KLMN"); | |||
assertThat(result.moduleUuid()).isEqualTo("EFGH"); | |||
assertThat(result.moduleUuidPath()).isEqualTo(".ABCD.EFGH."); | |||
assertThat(result.parentProjectId()).isEqualTo(2); | |||
assertThat(result.getRootUuid()).isEqualTo("EFGH"); | |||
assertThat(result.projectUuid()).isEqualTo("ABCD"); | |||
assertThat(result.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java"); | |||
assertThat(result.path()).isEqualTo("src/org/struts/RequestContext.java"); | |||
@@ -358,7 +361,7 @@ public class ComponentDaoTest { | |||
assertThat(results.get(0).getKey()).isEqualTo("org.struts:struts"); | |||
// Sub project of a project | |||
assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("ABCD"))).isEmpty(); | |||
assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("ABCD"))).extracting("uuid").containsOnly("ABCD"); | |||
// SUb projects of a component and a sub module | |||
assertThat(underTest.selectSubProjectsByComponentUuids(dbSession, newArrayList("HIJK", "FGHI"))).hasSize(2); | |||
@@ -569,9 +572,9 @@ public class ComponentDaoTest { | |||
.setLanguage("java") | |||
.setDescription("description") | |||
.setPath("src/org/struts/RequestContext.java") | |||
.setParentProjectId(3L) | |||
.setCopyResourceId(5L) | |||
.setDeveloperId(7L) | |||
.setRootUuid("uuid_3") | |||
.setCopyComponentUuid("uuid_5") | |||
.setDeveloperUuid("uuid_7") | |||
.setEnabled(true) | |||
.setCreatedAt(DateUtils.parseDate("2014-06-18")) | |||
.setAuthorizationUpdatedAt(123456789L); | |||
@@ -602,9 +605,9 @@ public class ComponentDaoTest { | |||
.setLanguage("java") | |||
.setDescription("description") | |||
.setPath("src/org/struts/RequestContext.java") | |||
.setParentProjectId(3L) | |||
.setCopyResourceId(5L) | |||
.setDeveloperId(7L) | |||
.setRootUuid("uuid_3") | |||
.setCopyComponentUuid("uuid_5") | |||
.setDeveloperUuid("uuid_7") | |||
.setEnabled(true) | |||
.setCreatedAt(DateUtils.parseDate("2014-06-18")) | |||
.setAuthorizationUpdatedAt(123456789L); | |||
@@ -634,7 +637,7 @@ public class ComponentDaoTest { | |||
.setScope("FIL") | |||
.setLanguage("java") | |||
.setPath("src/org/struts/RequestContext.java") | |||
.setParentProjectId(3L) | |||
.setRootUuid("uuid_3") | |||
.setEnabled(false) | |||
.setCreatedAt(DateUtils.parseDate("2014-06-18")) | |||
.setAuthorizationUpdatedAt(123456789L); | |||
@@ -664,9 +667,9 @@ public class ComponentDaoTest { | |||
.setLanguage("java2") | |||
.setDescription("description2") | |||
.setPath("src/org/struts/RequestContext2.java") | |||
.setParentProjectId(4L) | |||
.setCopyResourceId(6L) | |||
.setDeveloperId(9L) | |||
.setRootUuid("uuid_4") | |||
.setCopyComponentUuid("uuid_6") | |||
.setDeveloperUuid("uuid_9") | |||
.setEnabled(false) | |||
.setAuthorizationUpdatedAt(12345678910L); | |||
@@ -40,8 +40,9 @@ public class ComponentDtoTest { | |||
.setLanguage("java") | |||
.setDescription("desc") | |||
.setPath("src/org/struts/RequestContext.java") | |||
.setCopyResourceId(5L) | |||
.setParentProjectId(3L) | |||
.setCopyComponentUuid("uuid_5") | |||
.setRootUuid("uuid_3") | |||
.setDeveloperUuid("uuid_6") | |||
.setAuthorizationUpdatedAt(123456789L); | |||
assertThat(componentDto.getId()).isEqualTo(1L); | |||
@@ -54,8 +55,9 @@ public class ComponentDtoTest { | |||
assertThat(componentDto.path()).isEqualTo("src/org/struts/RequestContext.java"); | |||
assertThat(componentDto.language()).isEqualTo("java"); | |||
assertThat(componentDto.description()).isEqualTo("desc"); | |||
assertThat(componentDto.parentProjectId()).isEqualTo(3L); | |||
assertThat(componentDto.getCopyResourceId()).isEqualTo(5L); | |||
assertThat(componentDto.getRootUuid()).isEqualTo("uuid_3"); | |||
assertThat(componentDto.getCopyResourceUuid()).isEqualTo("uuid_5"); | |||
assertThat(componentDto.getDeveloperUuid()).isEqualTo("uuid_6"); | |||
assertThat(componentDto.getAuthorizationUpdatedAt()).isEqualTo(123456789L); | |||
} | |||
@@ -94,7 +94,7 @@ public class ComponentTesting { | |||
.setUuid(uuid) | |||
.setProjectUuid(uuid) | |||
.setModuleUuidPath(MODULE_UUID_PATH_SEP + uuid + MODULE_UUID_PATH_SEP) | |||
.setParentProjectId(null) | |||
.setRootUuid(uuid) | |||
.setKey("KEY_" + uuid) | |||
.setName("NAME_" + uuid) | |||
.setLongName("LONG_NAME_" + uuid) | |||
@@ -111,7 +111,7 @@ public class ComponentTesting { | |||
.setUuid(uuid) | |||
.setProjectUuid(uuid) | |||
.setModuleUuidPath(MODULE_UUID_PATH_SEP + uuid + MODULE_UUID_PATH_SEP) | |||
.setParentProjectId(null) | |||
.setRootUuid(uuid) | |||
.setKey(uuid) | |||
.setName(name) | |||
.setLongName(name) | |||
@@ -141,7 +141,7 @@ public class ComponentTesting { | |||
.setKey(view.key() + project.key()) | |||
.setName(project.name()) | |||
.setLongName(project.longName()) | |||
.setCopyResourceId(project.getId()) | |||
.setCopyComponentUuid(project.uuid()) | |||
.setScope(Scopes.FILE) | |||
.setQualifier(Qualifiers.PROJECT) | |||
.setPath(null) | |||
@@ -155,7 +155,7 @@ public class ComponentTesting { | |||
.setKey(developer.key() + ":" + project.key()) | |||
.setName(project.name()) | |||
.setLongName(project.longName()) | |||
.setCopyResourceId(project.getId()) | |||
.setCopyComponentUuid(project.uuid()) | |||
.setScope(Scopes.PROJECT) | |||
.setQualifier("DEV_PRJ") | |||
.setPath(null) | |||
@@ -168,7 +168,7 @@ public class ComponentTesting { | |||
.setProjectUuid(module.projectUuid()) | |||
.setModuleUuid(module.uuid()) | |||
.setModuleUuidPath(module.moduleUuidPath()) | |||
.setParentProjectId(module.getId()) | |||
.setRootUuid(module.uuid()) | |||
.setCreatedAt(new Date()) | |||
.setEnabled(true); | |||
} |
@@ -27,8 +27,6 @@ import javax.annotation.Nullable; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.component.Component; | |||
import org.sonar.api.resources.Qualifiers; | |||
import org.sonar.api.resources.Scopes; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbTester; | |||
@@ -87,27 +85,6 @@ public class ResourceDaoTest { | |||
assertThat(underTest.getRootProjectByComponentKey("unknown")).isNull(); | |||
} | |||
@Test | |||
public void should_insert_using_existing_session() { | |||
dbTester.prepareDbUnit(getClass(), "insert.xml"); | |||
ResourceDto file1 = new ResourceDto().setUuid("ABCD") | |||
.setKey("org.struts:struts:/src/main/java/org/struts/Action.java") | |||
.setDeprecatedKey("org.struts:struts:org.struts.Action").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE) | |||
.setLanguage("java").setName("Action").setLongName("org.struts.Action"); | |||
ResourceDto file2 = new ResourceDto().setUuid("BCDE") | |||
.setKey("org.struts:struts:/src/main/java/org/struts/Filter.java") | |||
.setDeprecatedKey("org.struts:struts:org.struts.Filter").setScope(Scopes.FILE).setQualifier(Qualifiers.FILE) | |||
.setLanguage("java").setName("Filter").setLongName("org.struts.Filter"); | |||
underTest.insertUsingExistingSession(file1, dbTester.getSession()); | |||
underTest.insertUsingExistingSession(file2, dbTester.getSession()); | |||
dbTester.getSession().rollback(); | |||
assertThat(dbTester.countRowsOfTable("projects")).isZero(); | |||
} | |||
@Test | |||
public void should_find_component_by_key() { | |||
dbTester.prepareDbUnit(getClass(), "fixture.xml"); |
@@ -147,7 +147,7 @@ public class ResourceIndexDaoTest { | |||
@Test | |||
public void restrict_indexed_combinations_to_400_characters() { | |||
String longName = repeat("a", 2_000); | |||
ComponentDto project = new ComponentDto().setUuid(ROOT_UUID).setKey("the_key").setName(longName).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT); | |||
ComponentDto project = new ComponentDto().setUuid(ROOT_UUID).setRootUuid(ROOT_UUID).setKey("the_key").setName(longName).setScope(Scopes.PROJECT).setQualifier(Qualifiers.PROJECT); | |||
DbSession session = dbTester.getSession(); | |||
dbTester.getDbClient().componentDao().insert(session, project); | |||
dbTester.getDbClient().snapshotDao().insert(session, new SnapshotDto().setComponentUuid(project.uuid()).setRootComponentUuid(project.uuid()).setLast(true)); |
@@ -25,6 +25,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.db.DbSession; | |||
import org.sonar.db.DbTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -38,6 +39,7 @@ public class ResourceKeyUpdaterDaoTest { | |||
@Rule | |||
public DbTester db = DbTester.create(System2.INSTANCE); | |||
private DbSession dbSession = db.getSession(); | |||
ComponentDbTester componentDb = new ComponentDbTester(db); | |||
ResourceKeyUpdaterDao underTest = db.getDbClient().resourceKeyUpdaterDao(); | |||
@@ -46,7 +48,7 @@ public class ResourceKeyUpdaterDaoTest { | |||
public void shouldUpdateKey() { | |||
db.prepareDbUnit(getClass(), "shared.xml"); | |||
underTest.updateKey(2, "struts:core"); | |||
underTest.updateKey("B", "struts:core"); | |||
db.assertDbUnit(getClass(), "shouldUpdateKey-result.xml", "projects"); | |||
} | |||
@@ -58,14 +60,15 @@ public class ResourceKeyUpdaterDaoTest { | |||
thrown.expect(IllegalStateException.class); | |||
thrown.expectMessage("Impossible to update key: a resource with \"org.struts:struts-ui\" key already exists."); | |||
underTest.updateKey(2, "org.struts:struts-ui"); | |||
underTest.updateKey("B", "org.struts:struts-ui"); | |||
} | |||
@Test | |||
public void shouldBulkUpdateKey() { | |||
db.prepareDbUnit(getClass(), "shared.xml"); | |||
underTest.bulkUpdateKey(1, "org.struts", "org.apache.struts"); | |||
underTest.bulkUpdateKey(dbSession, "A", "org.struts", "org.apache.struts"); | |||
dbSession.commit(); | |||
db.assertDbUnit(getClass(), "shouldBulkUpdateKey-result.xml", "projects"); | |||
} | |||
@@ -74,7 +77,8 @@ public class ResourceKeyUpdaterDaoTest { | |||
public void shouldBulkUpdateKeyOnOnlyOneSubmodule() { | |||
db.prepareDbUnit(getClass(), "shared.xml"); | |||
underTest.bulkUpdateKey(1, "struts-ui", "struts-web"); | |||
underTest.bulkUpdateKey(dbSession, "A", "struts-ui", "struts-web"); | |||
dbSession.commit(); | |||
db.assertDbUnit(getClass(), "shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml", "projects"); | |||
} | |||
@@ -86,14 +90,16 @@ public class ResourceKeyUpdaterDaoTest { | |||
thrown.expect(IllegalStateException.class); | |||
thrown.expectMessage("Impossible to update key: a resource with \"foo:struts-core\" key already exists."); | |||
underTest.bulkUpdateKey(1, "org.struts", "foo"); | |||
underTest.bulkUpdateKey(dbSession, "A", "org.struts", "foo"); | |||
dbSession.commit(); | |||
} | |||
@Test | |||
public void shouldNotUpdateAllSubmodules() { | |||
db.prepareDbUnit(getClass(), "shouldNotUpdateAllSubmodules.xml"); | |||
underTest.bulkUpdateKey(1, "org.struts", "org.apache.struts"); | |||
underTest.bulkUpdateKey(dbSession, "A", "org.struts", "org.apache.struts"); | |||
dbSession.commit(); | |||
db.assertDbUnit(getClass(), "shouldNotUpdateAllSubmodules-result.xml", "projects"); | |||
} | |||
@@ -107,14 +113,14 @@ public class ResourceKeyUpdaterDaoTest { | |||
thrown.expect(IllegalArgumentException.class); | |||
thrown.expectMessage("Component key length (405) is longer than the maximum authorized (400). '" + newLongProjectKey + ":file' was provided."); | |||
underTest.updateKey(project.getId(), newLongProjectKey); | |||
underTest.updateKey(project.uuid(), newLongProjectKey); | |||
} | |||
@Test | |||
public void shouldCheckModuleKeysBeforeRenaming() { | |||
db.prepareDbUnit(getClass(), "shared.xml"); | |||
Map<String, String> checkResults = underTest.checkModuleKeysBeforeRenaming(1, "org.struts", "foo"); | |||
Map<String, String> checkResults = underTest.checkModuleKeysBeforeRenaming("A", "org.struts", "foo"); | |||
assertThat(checkResults.size()).isEqualTo(3); | |||
assertThat(checkResults.get("org.struts:struts")).isEqualTo("foo:struts"); | |||
assertThat(checkResults.get("org.struts:struts-core")).isEqualTo("#duplicate_key#"); |
@@ -20,7 +20,6 @@ | |||
package org.sonar.db.issue; | |||
import java.util.List; | |||
import org.apache.ibatis.executor.result.DefaultResultHandler; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
@@ -51,52 +50,6 @@ public class IssueDaoTest { | |||
public DbTester dbTester = DbTester.create(System2.INSTANCE); | |||
IssueDao underTest = dbTester.getDbClient().issueDao(); | |||
@Test | |||
public void select_non_closed_issues_by_module() { | |||
dbTester.prepareDbUnit(getClass(), "shared.xml", "should_select_non_closed_issues_by_module.xml"); | |||
// 400 is a non-root module, we should find 2 issues from classes and one on itself | |||
DefaultResultHandler handler = new DefaultResultHandler(); | |||
underTest.selectNonClosedIssuesByModule(400, handler); | |||
assertThat(handler.getResultList()).hasSize(3); | |||
IssueDto issue = (IssueDto) handler.getResultList().get(0); | |||
assertThat(issue.getRuleRepo()).isNotNull(); | |||
assertThat(issue.getRule()).isNotNull(); | |||
assertThat(issue.getComponentKey()).isNotNull(); | |||
assertThat(issue.getProjectKey()).isEqualTo("struts"); | |||
// 399 is the root module, we should only find 1 issue on itself | |||
handler = new DefaultResultHandler(); | |||
underTest.selectNonClosedIssuesByModule(399, handler); | |||
assertThat(handler.getResultList()).hasSize(1); | |||
issue = (IssueDto) handler.getResultList().get(0); | |||
assertThat(issue.getComponentKey()).isEqualTo("struts"); | |||
assertThat(issue.getProjectKey()).isEqualTo("struts"); | |||
} | |||
/** | |||
* SONAR-5218 | |||
*/ | |||
@Test | |||
public void select_non_closed_issues_by_module_on_removed_project() { | |||
// All issues are linked on a project that is not existing anymore | |||
dbTester.prepareDbUnit(getClass(), "shared.xml", "should_select_non_closed_issues_by_module_on_removed_project.xml"); | |||
// 400 is a non-root module, we should find 2 issues from classes and one on itself | |||
DefaultResultHandler handler = new DefaultResultHandler(); | |||
underTest.selectNonClosedIssuesByModule(400, handler); | |||
assertThat(handler.getResultList()).hasSize(3); | |||
IssueDto issue = (IssueDto) handler.getResultList().get(0); | |||
assertThat(issue.getRuleRepo()).isNotNull(); | |||
assertThat(issue.getRule()).isNotNull(); | |||
assertThat(issue.getComponentKey()).isNotNull(); | |||
assertThat(issue.getProjectKey()).isNull(); | |||
} | |||
@Test | |||
public void selectByKeyOrFail() { | |||
prepareTables(); |
@@ -3,8 +3,8 @@ | |||
<projects id="1" kee="org.struts:struts-core:src/org/struts/RequestContext.java" deprecated_kee="org.struts:struts-core:src/org/struts/RequestContext.java" | |||
name="RequestContext.java" long_name="org.struts.RequestContext" | |||
uuid="GHIJ" project_uuid="ABCD" module_uuid="EFGH" module_uuid_path=".ABCD.EFGH." | |||
qualifier="FIL" scope="FIL" language="java" path="src/org/struts/RequestContext.java" root_id="3" | |||
description="description" enabled="[true]" copy_resource_id="5" person_id="7" | |||
qualifier="FIL" scope="FIL" language="java" path="src/org/struts/RequestContext.java" root_uuid="uuid_3" | |||
description="description" enabled="[true]" copy_component_uuid="uuid_5" developer_uuid="uuid_7" | |||
authorization_updated_at="123456789" created_at="2014-06-18" | |||
/> | |||