@Override public void executeRule(final TableInteRule rule) throws RuleException { Assert.notNull(rule, "整合规则对象rule为空"); Assert.notNull(rule.getRuleId(), "整合规则对象主键Id的rule.ruleid为空"); Assert.notNull( rule.getRuleType(), "整合规则对象规则类型rule.ruleType为空,可选值为['clean','rebuild','unique','merge']"); try { ruleExecuter.execute( new RuleSetter() { @Override public String getRuleId() { return rule.getRuleId(); } @Override public String getRuleType() { return rule.getRuleType(); } }); } catch (RuleException e) { // 李广彬:2014-7-11 新加入【不管是java出错 还是存储过程 将整合日志状态更新为失败状态】 Map<String, Object> params = new HashMap<String, Object>(); params.put("ruleId", rule.getRuleId()); List<DataInteLog> items = this.dataInteLog.find(params); if (items.size() > 0) { DataInteLog dil = items.get(0); dil.setOpStats(DataLogState.LOG_FAILURE.getState()); this.dataInteLog.update(dil); } throw e; } }
private DataInteLog insertDataInteLog( TableInteRule tableRule, String ruleId, DataLogState state, String processType) throws BusinessException { DataInteLog log = new DataInteLog(); log.setId(this.buildId("")); log.setRuleId(ruleId); log.setSourceDataSet1(tableRule.getDataSet1()); log.setSourceDataSet2(tableRule.getDataSet2()); // 2.1 创建一个虚拟结果数据集 DataSet resultSet = new DataSet(); resultSet.setDataSetId(this.buildId("")); log.setOpUser(tableRule.getCreateUser()); log.setRuleType(tableRule.getRuleType()); log.setResultDataSet(resultSet); log.setOpStats(state.getState()); log.setProcessType(processType); this.dataInteLog.save(log); return log; // 返回结果数据集的ID }
@Override public TableInteRule insertTableRule(TableInteRule tableRule) throws BusinessException { Assert.notNull(tableRule, "表数据整合规则不允许为空"); // 1. 生成整合规则的主键Id String ruleId = this.buildId(""); // 2.新插入整合规则对应的字段 for (ColumnInteRule rule : tableRule.getColumnRules()) { rule.setRuleId(ruleId); rule.setId(buildId("")); this.columnInteRuleDao.save(rule); insertAllChildRules(rule); } // 3.增加整合日志 tableRule.setRuleId(ruleId); this.insertDataInteLog( tableRule, ruleId, DataLogState.LOG_INIT, DataInteLog.PROCESS_TYPE_MANUAL); // 4.新插入表整合规则功能 this.save(tableRule); return tableRule; }