]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4923 Move mappings to correct package
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Tue, 14 Jan 2014 10:05:52 +0000 (11:05 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Tue, 14 Jan 2014 10:19:07 +0000 (11:19 +0100)
sonar-server/src/main/java/org/sonar/server/es/SearchNode.java
sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java
sonar-server/src/main/resources/com/sonar/search/active_rule_mapping.json [deleted file]
sonar-server/src/main/resources/com/sonar/search/rule_mapping.json [deleted file]
sonar-server/src/main/resources/org/sonar/server/es/config/mappings/active_rule_mapping.json [new file with mode: 0644]
sonar-server/src/main/resources/org/sonar/server/es/config/mappings/rule_mapping.json [new file with mode: 0644]
sonar-server/src/test/java/org/sonar/server/rule/ProfileRulesTest.java
sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java

index c91d73f2cecf676b07d7981b5b5501ee1eddb137..d9c8dbe3745ae1653a81cc0bdb4cd4590e7629d3 100644 (file)
@@ -48,7 +48,6 @@ public class SearchNode implements Startable {
   private static final Logger LOG = LoggerFactory.getLogger(SearchIndex.class);
 
   private static final String HTTP_ENABLED = "http.enabled";
-  private static final String INSTANCE_NAME = "sonarqube";
   static final String DATA_DIR = "data/es";
 
   private static final String DEFAULT_HEALTH_TIMEOUT = "30s";
index e5529a7e407f865fcc9a6e88e004cfbaf2940c0a..a23d406e7ce1ffe1e714979fab07a4a6784f112b 100644 (file)
@@ -20,9 +20,6 @@
 
 package org.sonar.server.rule;
 
-import org.sonar.server.es.SearchIndex;
-import org.sonar.server.es.SearchQuery;
-
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
 import org.apache.ibatis.session.SqlSession;
@@ -40,6 +37,8 @@ import org.sonar.core.qualityprofile.db.ActiveRuleDao;
 import org.sonar.core.qualityprofile.db.ActiveRuleDto;
 import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
 import org.sonar.core.rule.*;
+import org.sonar.server.es.SearchIndex;
+import org.sonar.server.es.SearchQuery;
 
 import java.io.IOException;
 import java.util.Arrays;
@@ -76,8 +75,8 @@ public class RuleRegistry {
   }
 
   public void start() {
-    searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_RULE, "/com/sonar/search/rule_mapping.json");
-    searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_ACTIVE_RULE, "/com/sonar/search/active_rule_mapping.json");
+    searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_RULE, "/org/sonar/server/es/config/mappings/rule_mapping.json");
+    searchIndex.addMappingFromClasspath(INDEX_RULES, TYPE_ACTIVE_RULE, "/org/sonar/server/es/config/mappings/active_rule_mapping.json");
   }
 
   public void bulkRegisterRules(Collection<RuleDto> rules, Multimap<Integer, RuleParamDto> paramsByRule, Multimap<Integer, RuleTagDto> tagsByRule) {
diff --git a/sonar-server/src/main/resources/com/sonar/search/active_rule_mapping.json b/sonar-server/src/main/resources/com/sonar/search/active_rule_mapping.json
deleted file mode 100644 (file)
index 8fef621..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-{
-  "active_rule": {
-    "_id": {
-      "path": "id"
-    },
-    "_parent": {
-      "type": "rule"
-    },
-    "properties": {
-      "id": {
-        "type": "integer",
-        "index": "not_analyzed"
-      },
-      "severity": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "profileId": {
-        "type": "integer",
-        "index": "not_analyzed"
-      },
-      "parentId": {
-        "type": "integer",
-        "index": "not_analyzed"
-      },
-      "inheritance": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "note": {
-        "properties": {
-          "data": {
-            "type": "string",
-            "index": "no"
-          },
-          "userLogin": {
-            "type": "string",
-            "index": "no"
-          },
-          "createdAt": {
-            "type": "date",
-            "format": "date_optional_time"
-          },
-          "updatedAt": {
-            "type": "date",
-            "format": "date_optional_time"
-          }
-        }
-      },
-      "params": {
-        "properties": {
-          "key": {
-            "type": "string",
-            "index": "no"
-          },
-          "value": {
-            "type": "string",
-            "index": "no"
-          }
-        }
-      }
-    }
-  }
-}
diff --git a/sonar-server/src/main/resources/com/sonar/search/rule_mapping.json b/sonar-server/src/main/resources/com/sonar/search/rule_mapping.json
deleted file mode 100644 (file)
index 7c39f03..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-{
-  "rule": {
-    "_id": {
-      "path": "id"
-    },
-    "properties": {
-      "id": {
-        "type": "integer",
-        "index": "not_analyzed"
-      },
-      "key": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "language": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "name": {
-        "type": "multi_field",
-        "fields": {
-          "name": { "type": "string", "index": "analyzed" },
-          "raw": { "type": "string", "index": "not_analyzed"}
-        }
-      },
-      "description": {
-        "type": "string",
-        "index": "no"
-      },
-      "parentKey": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "repositoryKey": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "severity": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "status": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "cardinality": {
-        "type": "string",
-        "index": "no"
-      },
-      "createdAt": {
-        "type": "date",
-        "format": "date_optional_time"
-      },
-      "updatedAt": {
-        "type": "date",
-        "format": "date_optional_time"
-      },
-      "note": {
-        "properties": {
-          "data": {
-            "type": "string",
-            "index": "no"
-          },
-          "userLogin": {
-            "type": "string",
-            "index": "no"
-          },
-          "createdAt": {
-            "type": "date",
-            "format": "date_optional_time"
-          },
-          "updatedAt": {
-            "type": "date",
-            "format": "date_optional_time"
-          }
-        }
-      },
-      "params": {
-        "properties": {
-          "key": {
-            "type": "string",
-            "index": "no"
-          },
-          "type": {
-            "type": "string",
-            "index": "no"
-          },
-          "defaultValue": {
-            "type": "string",
-            "index": "no"
-          },
-          "description": {
-            "type": "string",
-            "index": "no"
-          }
-        }
-      },
-      "systemTags": {
-        "type": "string",
-        "index": "not_analyzed"
-      },
-      "adminTags": {
-        "type": "string",
-        "index": "not_analyzed"
-      }
-    }
-  }
-}
diff --git a/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/active_rule_mapping.json b/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/active_rule_mapping.json
new file mode 100644 (file)
index 0000000..8fef621
--- /dev/null
@@ -0,0 +1,64 @@
+{
+  "active_rule": {
+    "_id": {
+      "path": "id"
+    },
+    "_parent": {
+      "type": "rule"
+    },
+    "properties": {
+      "id": {
+        "type": "integer",
+        "index": "not_analyzed"
+      },
+      "severity": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "profileId": {
+        "type": "integer",
+        "index": "not_analyzed"
+      },
+      "parentId": {
+        "type": "integer",
+        "index": "not_analyzed"
+      },
+      "inheritance": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "note": {
+        "properties": {
+          "data": {
+            "type": "string",
+            "index": "no"
+          },
+          "userLogin": {
+            "type": "string",
+            "index": "no"
+          },
+          "createdAt": {
+            "type": "date",
+            "format": "date_optional_time"
+          },
+          "updatedAt": {
+            "type": "date",
+            "format": "date_optional_time"
+          }
+        }
+      },
+      "params": {
+        "properties": {
+          "key": {
+            "type": "string",
+            "index": "no"
+          },
+          "value": {
+            "type": "string",
+            "index": "no"
+          }
+        }
+      }
+    }
+  }
+}
diff --git a/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/rule_mapping.json b/sonar-server/src/main/resources/org/sonar/server/es/config/mappings/rule_mapping.json
new file mode 100644 (file)
index 0000000..7c39f03
--- /dev/null
@@ -0,0 +1,108 @@
+{
+  "rule": {
+    "_id": {
+      "path": "id"
+    },
+    "properties": {
+      "id": {
+        "type": "integer",
+        "index": "not_analyzed"
+      },
+      "key": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "language": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "name": {
+        "type": "multi_field",
+        "fields": {
+          "name": { "type": "string", "index": "analyzed" },
+          "raw": { "type": "string", "index": "not_analyzed"}
+        }
+      },
+      "description": {
+        "type": "string",
+        "index": "no"
+      },
+      "parentKey": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "repositoryKey": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "severity": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "status": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "cardinality": {
+        "type": "string",
+        "index": "no"
+      },
+      "createdAt": {
+        "type": "date",
+        "format": "date_optional_time"
+      },
+      "updatedAt": {
+        "type": "date",
+        "format": "date_optional_time"
+      },
+      "note": {
+        "properties": {
+          "data": {
+            "type": "string",
+            "index": "no"
+          },
+          "userLogin": {
+            "type": "string",
+            "index": "no"
+          },
+          "createdAt": {
+            "type": "date",
+            "format": "date_optional_time"
+          },
+          "updatedAt": {
+            "type": "date",
+            "format": "date_optional_time"
+          }
+        }
+      },
+      "params": {
+        "properties": {
+          "key": {
+            "type": "string",
+            "index": "no"
+          },
+          "type": {
+            "type": "string",
+            "index": "no"
+          },
+          "defaultValue": {
+            "type": "string",
+            "index": "no"
+          },
+          "description": {
+            "type": "string",
+            "index": "no"
+          }
+        }
+      },
+      "systemTags": {
+        "type": "string",
+        "index": "not_analyzed"
+      },
+      "adminTags": {
+        "type": "string",
+        "index": "not_analyzed"
+      }
+    }
+  }
+}
index 8f0554a05b34e86adef1584b5bf194888ecae9a4..3f688690871a5bc75a572200160f722e43555c07 100644 (file)
  */
 package org.sonar.server.rule;
 
-import org.sonar.server.es.SearchIndex;
-import org.sonar.server.es.SearchNode;
-
 import com.github.tlrx.elasticsearch.test.EsSetup;
 import org.apache.commons.io.IOUtils;
 import org.elasticsearch.client.Requests;
+import org.elasticsearch.common.settings.ImmutableSettings;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.sonar.api.config.Settings;
 import org.sonar.api.rule.Severity;
 import org.sonar.core.profiling.Profiling;
+import org.sonar.server.es.SearchIndex;
+import org.sonar.server.es.SearchNode;
 import org.sonar.server.qualityprofile.Paging;
 import org.sonar.server.qualityprofile.QProfileRule;
 import org.sonar.test.TestUtils;
@@ -48,7 +48,10 @@ public class ProfileRulesTest {
 
   @Before
   public void setUp() throws Exception {
-    esSetup = new EsSetup();
+    esSetup = new EsSetup(ImmutableSettings.builder()
+      .loadFromUrl(SearchNode.class.getResource("config/elasticsearch.json"))
+      .build()
+      );
     esSetup.execute(EsSetup.deleteAll());
 
     SearchNode searchNode = mock(SearchNode.class);
index 6a560e82a00a4f000caa90e882b1fa03520c7c02..a4f431826c18960b75611c6002ac5fba5745cb7e 100644 (file)
@@ -20,9 +20,6 @@
 
 package org.sonar.server.rule;
 
-import org.sonar.server.es.SearchIndex;
-import org.sonar.server.es.SearchNode;
-
 import com.github.tlrx.elasticsearch.test.EsSetup;
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.ImmutableList;
@@ -31,6 +28,7 @@ import com.google.common.collect.Multimap;
 import org.apache.commons.io.IOUtils;
 import org.apache.ibatis.session.SqlSession;
 import org.elasticsearch.common.collect.Lists;
+import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.search.SearchHit;
 import org.junit.After;
 import org.junit.Before;
@@ -45,6 +43,8 @@ import org.sonar.core.qualityprofile.db.ActiveRuleDao;
 import org.sonar.core.qualityprofile.db.ActiveRuleDto;
 import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
 import org.sonar.core.rule.*;
+import org.sonar.server.es.SearchIndex;
+import org.sonar.server.es.SearchNode;
 import org.sonar.test.TestUtils;
 
 import java.io.IOException;
@@ -86,7 +86,7 @@ public class RuleRegistryTest {
   public void setUp() throws Exception {
     when(myBatis.openSession()).thenReturn(session);
 
-    esSetup = new EsSetup();
+    esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(SearchNode.class.getResource("config/elasticsearch.json")).build());
     esSetup.execute(EsSetup.deleteAll());
 
     SearchNode node = mock(SearchNode.class);