Beispiel #1
0
  /**
   * Execute method of the rule. This holds the rule conditions and actions. The required objects
   * are initialized through init() method. return - execution result of rule either SUCCESS or
   * FAILURE
   */
  public static RulesResult execute(RulesContext ctx, String ruleId) throws RIFPOJORulesException {

    // Construct rules result object
    RulesResult rulesResult = new RulesResult(ruleId);
    String applicationNumber = null;
    boolean flag = false;

    ProviderEnrollmentDelegate providerEnrollmentDelegate = null;

    if (ctx != null) {

      List<Object> inputObjs = ctx.getContextObject();

      applicationNumber = (String) inputObjs.get(0);
      if (applicationNumber == null) {
        LOG.error(
            "Input Object recallProviderData is  null during intialization for the rule " + ruleId);
        throw new RIFPOJORulesException(
            "Unable to initialize the required rules objects for rule " + ruleId);
      }

      providerEnrollmentDelegate = (ProviderEnrollmentDelegate) inputObjs.get(1);
      if (providerEnrollmentDelegate == null) {
        LOG.error(
            "Input Object providerEnrollmentDelegate is  null during intialization for the rule "
                + ruleId);
        throw new RIFPOJORulesException(
            "Unable to initialize the required rules objects for rule " + ruleId);
      }

    } else {
      LOG.error("Input Context Object is null during intialization for the rule " + ruleId);
      throw new RIFPOJORulesException(
          "Unable to initialize the required rules objects for rule " + ruleId);
    }
    LOG.info("Executing the actions for the rule " + ruleId);

    try {
      flag = providerEnrollmentDelegate.getApplicationLockedDetail(applicationNumber);

      if (flag == false) {
        rulesResult.setReturnValue(ProviderDataConstants.PRV_ENR_FAILURE);
      }

      rulesResult.setRuleStatus(true);
    } catch (ApplicationLockedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return rulesResult;
  }