From 41b110181e9d459451a85dc6fa3be4a8b497ea6b Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Sat, 31 Dec 2011 09:49:44 +0100 Subject: Fix some quality flaws --- .../sonar/core/resource/ResourceIndexerDao.java | 10 +-- .../sonar/core/resource/ResourceIndexerFilter.java | 71 --------------------- .../sonar/core/resource/ResourceIndexerQuery.java | 74 ++++++++++++++++++++++ 3 files changed, 79 insertions(+), 76 deletions(-) delete mode 100644 sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerFilter.java create mode 100644 sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerQuery.java (limited to 'sonar-core/src') diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java index 8e737501011..37fc1dc8783 100644 --- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java +++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java @@ -69,7 +69,7 @@ public class ResourceIndexerDao { final SqlSession session = mybatis.openSession(ExecutorType.BATCH); try { final ResourceIndexerMapper mapper = session.getMapper(ResourceIndexerMapper.class); - session.select("selectRootProjectIds", /* workaround to get booleans */ResourceIndexerFilter.create(), new ResultHandler() { + session.select("selectRootProjectIds", /* workaround to get booleans */ResourceIndexerQuery.create(), new ResultHandler() { public void handleResult(ResultContext context) { Integer rootProjectId = (Integer) context.getResultObject(); doIndexProject(rootProjectId, session, mapper); @@ -85,13 +85,13 @@ public class ResourceIndexerDao { private void doIndexProject(int rootProjectId, SqlSession session, final ResourceIndexerMapper mapper) { // non indexed resources - ResourceIndexerFilter filter = ResourceIndexerFilter.create() + ResourceIndexerQuery query = ResourceIndexerQuery.create() .setNonIndexedOnly(true) .setQualifiers(NOT_RENAMABLE_QUALIFIERS) .setScopes(NOT_RENAMABLE_SCOPES) .setRootProjectId(rootProjectId); - session.select("selectResources", filter, new ResultHandler() { + session.select("selectResources", query, new ResultHandler() { public void handleResult(ResultContext context) { ResourceDto resource = (ResourceDto) context.getResultObject(); doIndex(resource, mapper); @@ -100,13 +100,13 @@ public class ResourceIndexerDao { // some resources can be renamed, so index must be regenerated // -> delete existing rows and create them again - filter = ResourceIndexerFilter.create() + query = ResourceIndexerQuery.create() .setNonIndexedOnly(false) .setQualifiers(RENAMABLE_QUALIFIERS) .setScopes(RENAMABLE_SCOPES) .setRootProjectId(rootProjectId); - session.select("selectResources", filter, new ResultHandler() { + session.select("selectResources", query, new ResultHandler() { public void handleResult(ResultContext context) { ResourceDto resource = (ResourceDto) context.getResultObject(); diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerFilter.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerFilter.java deleted file mode 100644 index a8a823078db..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerFilter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -package org.sonar.core.resource; - -public final class ResourceIndexerFilter { - private boolean _true = true; - private Integer rootProjectId = null; - private String[] scopes = null; - private String[] qualifiers = null; - private boolean nonIndexedOnly=false; - - private ResourceIndexerFilter() { - } - - public static ResourceIndexerFilter create() { - return new ResourceIndexerFilter(); - } - - public String[] getScopes() { - return scopes; - } - - public String[] getQualifiers() { - return qualifiers; - } - - public ResourceIndexerFilter setScopes(String[] scopes) { - this.scopes = scopes; - return this; - } - - public ResourceIndexerFilter setQualifiers(String[] qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - public Integer getRootProjectId() { - return rootProjectId; - } - - public ResourceIndexerFilter setRootProjectId(Integer i) { - this.rootProjectId = i; - return this; - } - - public boolean isNonIndexedOnly() { - return nonIndexedOnly; - } - - public ResourceIndexerFilter setNonIndexedOnly(boolean b) { - this.nonIndexedOnly = b; - return this; - } -} diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerQuery.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerQuery.java new file mode 100644 index 00000000000..4c45f846f83 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerQuery.java @@ -0,0 +1,74 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.core.resource; + +final class ResourceIndexerQuery { + // Workaround to inject booleans into mybatis mappers. It avoids declaring mappers + // dedicated to Oracle and SQLServer + public final boolean _true = true; //NOSONAR + + private Integer rootProjectId = null; + private String[] scopes = null; + private String[] qualifiers = null; + private boolean nonIndexedOnly=false; + + private ResourceIndexerQuery() { + } + + public static ResourceIndexerQuery create() { + return new ResourceIndexerQuery(); + } + + public String[] getScopes() { + return scopes; + } + + public String[] getQualifiers() { + return qualifiers; + } + + public ResourceIndexerQuery setScopes(String[] scopes) { + this.scopes = scopes; + return this; + } + + public ResourceIndexerQuery setQualifiers(String[] qualifiers) { + this.qualifiers = qualifiers; + return this; + } + + public Integer getRootProjectId() { + return rootProjectId; + } + + public ResourceIndexerQuery setRootProjectId(Integer i) { + this.rootProjectId = i; + return this; + } + + public boolean isNonIndexedOnly() { + return nonIndexedOnly; + } + + public ResourceIndexerQuery setNonIndexedOnly(boolean b) { + this.nonIndexedOnly = b; + return this; + } +} -- cgit v1.2.3