
package nc.bs.ic.m4i.sign;


import nc.bs.ic.general.rule.after.UpdateSCOnhandRule;
import nc.bs.ic.general.rule.before.InOutAuditDateCheck;
import nc.bs.ic.general.sign.ISignBP;
import nc.bs.ic.general.sign.ISignRuleProvider;
import nc.bs.ic.general.sign.SignBPTemplate;
import nc.bs.ic.m4i.base.BPPlugInPoint;
import nc.bs.ic.m4i.sign.rule.AfterSignRuleForFinanceProcess;
import nc.bs.ic.m4i.sign.rule.AfterSignRuleForLiabilityProcess;
import nc.bs.ic.m4i.sign.rule.AfterSignRuleForMatterApp;
import nc.bs.ic.m4i.sign.rule.AfterSignRuleSyncOutToMesProcess;
import nc.bs.scmpub.rule.VOSagaFrozenValidateRule;
import nc.impl.pubapp.pattern.rule.processer.AroundProcesser;
import nc.vo.ic.m4i.entity.GeneralOutVO;

public class SignBP implements ISignBP<GeneralOutVO>, ISignRuleProvider<GeneralOutVO> {

    public void addAfterRule(GeneralOutVO[] vos, AroundProcesser<GeneralOutVO> processor) {
        processor.addAfterRule(new UpdateSCOnhandRule(false, false));
        processor.addAfterRule(new AfterSignRuleForFinanceProcess());
        processor.addAfterRule(new AfterSignRuleForLiabilityProcess());
        processor.addAfterRule(new AfterSignRuleForMatterApp());
        processor.addAfterRule(new AfterSignRuleSyncOutToMesProcess());
    }

    public void addBeforeRule(GeneralOutVO[] vos, AroundProcesser<GeneralOutVO> processor) {
        processor.addBeforeRule(new VOSagaFrozenValidateRule(true));
        processor.addBeforeRule(new InOutAuditDateCheck());
    }

    public GeneralOutVO[] sign(GeneralOutVO[] bills) {
        SignBPTemplate<GeneralOutVO> insertBP = new SignBPTemplate(BPPlugInPoint.SignAction, this);
        GeneralOutVO[] resultVOs = (GeneralOutVO[]) insertBP.sign(bills);
        return resultVOs;
    }

}
