All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.schoolwow.quickdao.module.database.dml.flow.common.CheckReasonInstanceMapFlow Maven / Gradle / Ivy

There is a newer version: 5.3.1
Show newest version
package cn.schoolwow.quickdao.module.database.dml.flow.common;

import cn.schoolwow.quickdao.domain.database.dml.CheckStrategy;
import cn.schoolwow.quickdao.module.database.dml.domain.ManipulationOption;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.util.HashMap;
import java.util.Map;

public class CheckReasonInstanceMapFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        ManipulationOption manipulationOption = (ManipulationOption) flowContext.checkData("manipulationOption");
        Map instanceReasonMap = (Map) flowContext.getData("instanceReasonMap", new HashMap());

        if(!instanceReasonMap.isEmpty()){
            flowContext.remark("存在不符合字段约束的实例");
            if(CheckStrategy.CheckAndThrow.equals(manipulationOption.checkStrategy)){
                String reason = instanceReasonMap.values().iterator().next();
                throw new IllegalArgumentException("实例数组存在不符合字段约束的实例!个数:"+instanceReasonMap.size()+",部分违反字段约束原因:"+reason);
            }
        }
    }

    @Override
    public String name() {
        return "检查字段约束策略实例列表";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy