Delete attribute
authorFengLiang <feng.liang1@zte.com.cn>
Wed, 1 Mar 2017 01:37:38 +0000 (09:37 +0800)
committerFengLiang <feng.liang1@zte.com.cn>
Wed, 1 Mar 2017 01:37:38 +0000 (09:37 +0800)
Change-Id: I161d1966347fad654d1ea4f418d4d7cb7f69dbb3
Issue-ID:HOLMES-47
Signed-off-by: FengLiang <feng.liang1@zte.com.cn>
engine-d/pom.xml
engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java
engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java
engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java
engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java
engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java
engine-d/src/test/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapperTest.java
engine-d/src/test/java/org/openo/holmes/engine/wrapper/RuleMgtWrapperTest.java
pom.xml

index 9176aa0..b47bf62 100644 (file)
@@ -53,7 +53,6 @@
         <dependency>
             <groupId>org.easymock</groupId>
             <artifactId>easymock</artifactId>
-            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.drools</groupId>
             <scope>test</scope>
         </dependency>
 
-
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
index 8b20ac1..23600e8 100644 (file)
@@ -21,8 +21,10 @@ import io.dropwizard.db.DataSourceFactory;
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
 import org.hibernate.validator.constraints.NotEmpty;
+import org.jvnet.hk2.annotations.Service;
 import org.openo.holmes.common.config.MQConfig;
 
+@Service
 public class EngineDAppConfig extends Configuration {
 
     @NotEmpty
@@ -31,6 +33,9 @@ public class EngineDAppConfig extends Configuration {
     @NotEmpty
     private String apidescription = "Holmes rule management rest API";
 
+    @NotEmpty
+    private String msbServerAddr;
+
     @JsonProperty
     @NotNull
     @Valid
@@ -57,6 +62,11 @@ public class EngineDAppConfig extends Configuration {
         this.database = dataSourceFactory;
     }
 
+    @JsonProperty
+    public String getMsbServerAddr() {
+        return msbServerAddr;
+    }
+
     public String getApidescription() {
         return apidescription;
     }
index 4370054..0c00102 100644 (file)
@@ -27,7 +27,7 @@ import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
 public abstract class CorrelationRuleDao {
 
 
-    @SqlQuery("SELECT * FROM APLUS_RULE WHERE enable=:enable")
+    @SqlQuery("SELECT * FROM aplus_rule WHERE enable=:enable")
     public abstract List<CorrelationRule> queryRuleByEnable(@Bind("enable") int enable);
 
     public List<CorrelationRule> queryRuleByRuleEnable(int enable) {
index 6ce0fb6..9c46b58 100644 (file)
@@ -39,9 +39,7 @@ public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> {
         correlationRule.setModifier(resultSet.getString("updator"));
         correlationRule.setUpdateTime(resultSet.getDate("updateTime"));
         correlationRule.setParams((Properties) resultSet.getObject("params"));
-        correlationRule.setDomain(resultSet.getString("domain"));
         correlationRule.setContent(resultSet.getString("content"));
-        correlationRule.setIsManual(resultSet.getInt("isManual"));
         correlationRule.setVendor(resultSet.getString("vendor"));
         correlationRule.setPackageName(resultSet.getString("package"));
         return correlationRule;
index 9b83002..0ed452a 100644 (file)
@@ -134,11 +134,12 @@ public class DroolsEngine {
     private void initDeployRule() throws CorrelationException {
         List<CorrelationRule> rules = ruleMgtWrapper.queryRuleByEnable(ENABLE);
 
-        if (!rules.isEmpty()) {
-            for (CorrelationRule rule : rules) {
-                if (rule.getContent() != null) {
-                    deployRuleFromDB(rule.getContent());
-                }
+        if (rules.isEmpty()) {
+            return;
+        }
+        for (CorrelationRule rule : rules) {
+            if (rule.getContent() != null) {
+                deployRuleFromDB(rule.getContent());
             }
         }
     }
index 7df791d..5a9ce8f 100644 (file)
@@ -39,9 +39,6 @@ public class RuleMgtWrapper {
 
         List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class)
             .queryRuleByRuleEnable(enable);
-        if (ruleTemp == null) {
-            throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
-        }
         return ruleTemp;
     }
 }
index e5eccf8..6e43f86 100644 (file)
@@ -44,9 +44,7 @@ public class CorrelationRuleMapperTest {
         expect(resultSet.getString("updator")).andReturn("");\r
         expect(resultSet.getDate("updateTime")).andReturn(new Date(System.currentTimeMillis()));\r
         expect(resultSet.getObject("params")).andReturn(new Properties());\r
-        expect(resultSet.getString("domain")).andReturn("");\r
         expect(resultSet.getString("content")).andReturn("");\r
-        expect(resultSet.getInt("isManual")).andReturn(0);\r
         expect(resultSet.getString("vendor")).andReturn("");\r
         expect(resultSet.getString("package")).andReturn("");\r
 \r
index 593b1ce..fab68df 100644 (file)
@@ -48,20 +48,6 @@ public class RuleMgtWrapperTest {
         PowerMock.resetAll();\r
     }\r
 \r
-    @Test\r
-    public void queryRuleByEnable_ruletemp_is_null() throws CorrelationException {\r
-        int enable = 3;\r
-\r
-        thrown.expect(CorrelationException.class);\r
-\r
-        CorrelationRuleDao correlationRuleDao = PowerMock.createMock(CorrelationRuleDao.class);\r
-        expect(daoUtil.getJdbiDaoByOnDemand(anyObject(Class.class))).andReturn(correlationRuleDao);\r
-        expect(correlationRuleDao.queryRuleByRuleEnable(anyInt())).andReturn(null);\r
-        PowerMock.replayAll();\r
-        ruleMgtWrapper.queryRuleByEnable(enable);\r
-        PowerMock.verifyAll();\r
-    }\r
-\r
     @Test\r
     public void queryRuleByEnable_normal() throws CorrelationException {\r
         int enable = 3;\r
diff --git a/pom.xml b/pom.xml
index c474eba..06c8aa4 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                 <artifactId>swagger-sdk</artifactId>
                 <version>1.1.0-SNAPSHOT</version>
             </dependency>
+
+            <dependency>
+                <groupId>org.apache.httpcomponents</groupId>
+                <artifactId>httpclient</artifactId>
+                <version>4.3.6</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>