<commit_before>package top.cardone.configuration.action;

import com.google.common.collect.Maps;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.util.CollectionUtils;
import top.cardone.configuration.service.DictionaryService;
import top.cardone.context.ApplicationContextHolder;
import top.cardone.context.util.MapUtils;
import top.cardone.core.util.action.Action0;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.Map;

/**
 * Created by cardo on 2017/10/25 0025.
 */
@Log4j2
public class IfAction implements Action0 {
    @Setter
    private Map<String, String> findOne;

    @Setter
    private String[] actionBeanIds;

    @Setter
    private Action0[] actionBeans;

    @Setter
    private Integer delay = 120;

    @Override
    public void action() {
        if (ArrayUtils.isEmpty(actionBeanIds)) {
            return;
        }

        if (CollectionUtils.isEmpty(findOne)) {
            return;
        }

        Map<String, Object> dictionary = ApplicationContextHolder.getBean(DictionaryService.class).findOne(findOne);

        if (CollectionUtils.isEmpty(dictionary)) {
            return;
        }

        String value = MapUtils.getString(dictionary, "value_", "no");

        if (!BooleanUtils.toBoolean(value)) {
            return;
        }

        Date lastModifiedDate = (Date) MapUtils.getObject(dictionary, "last_modified_date");

        LocalDateTime delayTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(lastModifiedDate.getTime()), ZoneId.systemDefault()).plusSeconds(delay);

        if (delayTime.isAfter(LocalDateTime.now())) {
            return;
        }

        Map<String, Object> save = Maps.newHashMap();

        save.putAll(findOne);
        save.put("value", "no");<commit_msg>升级服务支持多个数据源<commit_after>package top.cardone.configuration.action;

import com.google.common.collect.Maps;
import lombok.Setter;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.util.CollectionUtils;
import top.cardone.configuration.service.DictionaryService;
import top.cardone.context.ApplicationContextHolder;
import top.cardone.context.util.MapUtils;
import top.cardone.core.util.action.Action0;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
import java.util.Map;

/**
 * Created by cardo on 2017/10/25 0025.
 */
@Log4j2
public class IfAction implements Action0 {
    @Setter
    private Map<String, String> findOne;

    @Setter
    private String[] actionBeanIds;

    @Setter
    private Action0[] actionBeans;

    @Setter
    private Integer delay = 120;

    @Override
    public void action() {
        if (ArrayUtils.isEmpty(actionBeanIds) && ArrayUtils.isEmpty(actionBeans)) {
            return;
        }

        if (CollectionUtils.isEmpty(findOne)) {
            return;
        }

        Map<String, Object> dictionary = ApplicationContextHolder.getBean(DictionaryService.class).findOne(findOne);

        if (CollectionUtils.isEmpty(dictionary)) {
            return;
        }

        String value = MapUtils.getString(dictionary, "value_", "no");

        if (!BooleanUtils.toBoolean(value)) {
            return;
        }

        Date lastModifiedDate = (Date) MapUtils.getObject(dictionary, "last_modified_date");

        LocalDateTime delayTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(lastModifiedDate.getTime()), ZoneId.systemDefault()).plusSeconds(delay);

        if (delayTime.isAfter(LocalDateTime.now())) {
            return;
        }

        Map<String, Object> save = Maps.newHashMap();

        save.putAll(findOne);
        save.put("value", "no");
{'fraction_non_alphanumeric': 0.11128244667180673, 'fraction_numerical': 0.012850167052171678, 'mean_word_length': 3.276923076923077, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6986911', 'n_tokens_mistral': 1192, 'n_tokens_neox': 1124, 'n_words': 212}