/**
  * Returns the value of {@code appliedAlgo} property.
  *
  * @return appliedAlgo
  */
 public String getAppliedAlgo() {
   if (selectedPolicy != null) {
     log.debug("Get  AppliedAlgo: " + selectedPolicy.getRuleCombAlgo());
     return selectedPolicy.getRuleCombAlgo();
   }
   log.debug("Get  AppliedAlgo: " + null);
   return null;
 }
  /**
   * Returns the value of {@code appliedTarget} property.
   *
   * @return appliedTarget
   */
  public Target getAppliedTarget() {
    if (selectedPolicy != null) {
      appliedTarget = daoPolicy.getTarget(selectedPolicy.getPkPolicy());
    }
    log.debug("Get  appliedTarget: " + appliedTarget);

    return appliedTarget;
  }
 /**
  * Returns the value of {@code ruleList} property.
  *
  * @return ruleList
  */
 public ArrayList<Rule> getRuleList() {
   if (selectedPolicy != null) {
     log.debug("Getting  ruleList ");
     return (ArrayList<Rule>) daoPolicy.selectRules(selectedPolicy.getPkPolicy());
   }
   log.debug("Get  ruleList: " + ruleList);
   return this.ruleList;
 }
  /** Saves the updated {@code Policy} instance in the database. */
  @SuppressWarnings({"rawtypes", "unchecked"})
  public void saveUpdatePolicy() {
    RequestContext context = RequestContext.getCurrentInstance();

    // Ensuring that user has entered a PolicyID
    if (this.selectedPolicy.getPolicyId() == null) {
      log.info("Name cannot be empty.");

      context.execute("noNameDialog.show()");
      return;
    }

    // Ensuring that user has entered a Description
    if (this.selectedPolicy.getDescription() == null) {
      log.info("Description cannot be empty.");
      context.execute("noDescriptionDialog.show()");
      return;
    }

    // Ensuring that user has selected a rule Combining Algorithm
    if (this.selectedPolicy.getRuleCombAlgo() == null
        || this.selectedPolicy.getRuleCombAlgo().equals("Select Rule Combining Algorithm ")) {
      log.info("Rule combining algorithm must be provided.");
      context.execute("noRuleCombDialog.show()");
      return;
    }
    // Casting ArrayList into Set, because updatePolicy only accepts Set
    Set rules = new HashSet((ArrayList<Rule>) daoPolicy.selectRules(selectedPolicy.getPkPolicy()));
    // Updating Policy
    daoPolicy.updatePolicy(
        selectedPolicy.getPkPolicy(),
        name,
        description,
        selectedPolicy.getRuleCombAlgo(),
        appliedTarget,
        rules);
    // Reinitializing all the local variables

    appliedTarget = null;
    allRule = null;
    this.setOperationFail(false);
    context.closeDialog(this);
    log.info("Updated policy saved successfully.");
  }