Beispiel #1
0
 private void importActiveRules(RulesDao rulesDao, RulesProfile profile) {
   for (Iterator<ActiveRule> iar = profile.getActiveRules(true).iterator(); iar.hasNext(); ) {
     ActiveRule activeRule = iar.next();
     Rule unMarshalledRule = activeRule.getRule();
     Rule matchingRuleInDb =
         rulesDao.getRuleByKey(unMarshalledRule.getRepositoryKey(), unMarshalledRule.getKey());
     if (matchingRuleInDb == null) {
       LoggerFactory.getLogger(getClass())
           .error(
               "Unable to find active rule "
                   + unMarshalledRule.getRepositoryKey()
                   + ":"
                   + unMarshalledRule.getKey());
       iar.remove();
       continue;
     }
     activeRule.setRule(matchingRuleInDb);
     activeRule.setRulesProfile(profile);
     activeRule.getActiveRuleParams();
     for (Iterator<ActiveRuleParam> irp = activeRule.getActiveRuleParams().iterator();
         irp.hasNext(); ) {
       ActiveRuleParam activeRuleParam = irp.next();
       RuleParam unMarshalledRP = activeRuleParam.getRuleParam();
       RuleParam matchingRPInDb = rulesDao.getRuleParam(matchingRuleInDb, unMarshalledRP.getKey());
       if (matchingRPInDb == null) {
         LoggerFactory.getLogger(getClass())
             .error("Unable to find active rule parameter " + unMarshalledRP.getKey());
         irp.remove();
         continue;
       }
       activeRuleParam.setActiveRule(activeRule);
       activeRuleParam.setRuleParam(matchingRPInDb);
     }
   }
 }
Beispiel #2
0
 private void importAlerts(RulesProfile profile) {
   if (profile.getAlerts() != null) {
     for (Iterator<Alert> ia = profile.getAlerts().iterator(); ia.hasNext(); ) {
       Alert alert = ia.next();
       Metric unMarshalledMetric = alert.getMetric();
       String validKey = unMarshalledMetric.getKey();
       Metric matchingMetricInDb = session.getSingleResult(Metric.class, "key", validKey);
       if (matchingMetricInDb == null) {
         LoggerFactory.getLogger(getClass()).error("Unable to find metric " + validKey);
         ia.remove();
         continue;
       }
       alert.setMetric(matchingMetricInDb);
       alert.setRulesProfile(profile);
     }
   }
 }