# BankFlagContextValueManagerImpl.java

    package com.mycim.server.ctx.exec.manager.impl;

    import com.fa.sesa.threadlocal.LocalContext;
    import com.mycim.framework.utils.lang.StringUtils;
    import com.mycim.server.base.manager.NamedObjectManager;
    import com.mycim.server.ctx.exec.manager.BankFlagContextValueManager;
    import com.mycim.server.ctx.manager.ContextValueManager;
    import com.mycim.valueobject.ObjectList;
    import com.mycim.valueobject.consts.ContextNames;
    import com.mycim.valueobject.context.dto.QueryContextValueDTO;
    import com.mycim.valueobject.prp.BankFlagContextValue;
    import com.mycim.valueobject.prp.ContextValue;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import org.springframework.transaction.annotation.Transactional;

    @Service
    @Transactional
    public class BankFlagContextValueManagerImpl implements BankFlagContextValueManager {

        @Autowired
        ContextValueManager contextValueManager;

        @Autowired
        NamedObjectManager namedObjectManager;

        private Long getBankInContextRrn() {
            return namedObjectManager.getNamedObjectRrn(ContextNames.BANK_FLAG_CONTEXT, LocalContext.getFacilityRrn(),
                                                        ObjectList.CONTEXT_KEY);
        }

        private BankFlagContextValue buildNewBankFlagContextValue(Long facilityRrn) {
            return new BankFlagContextValue(getBankInContextRrn());
        }

        @Override
        public String getBankInFlagByProcessInfo(QueryContextValueDTO dto) {
            BankFlagContextValue ctx = buildNewBankFlagContextValue(dto.getFacilityRrn());

            ctx.setProductRrn(dto.getProductRrn());
            ctx.setProcessRrn(dto.getProcessRrn());
            ctx.setProcessVersion(dto.getProcessVersion());
            ctx.setRouteRrn(dto.getRouteRrn());
            ctx.setOperationRrn(dto.getOperationRrn());

            ContextValue contextValue = contextValueManager.simulateContextValue(ctx);

            if (contextValue != null && StringUtils.isNotBlank(contextValue.getResultValue1())) {
                return contextValue.getResultValue1();
            }
            return StringUtils.EMPTY;
        }

    }