Package org.apache.imperius.spl.parser.statements.impl

Source Code of org.apache.imperius.spl.parser.statements.impl.PolicyGroup

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License. 
*/
//

/**
* @author Neeraj Joshi <jneeraj@us.ibm.com>
*
*/
package org.apache.imperius.spl.parser.statements.impl;

import java.util.logging.Logger;

import org.apache.imperius.spl.core.Actuator;
import org.apache.imperius.spl.core.DataCollector;
import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
import org.apache.imperius.spl.parser.exceptions.SPLException;
import org.apache.imperius.spl.parser.statements.EvaluationResults;
import org.apache.imperius.spl.parser.statements.PolicyStatement;
import org.apache.imperius.util.SPLLogger;


public class PolicyGroup implements PolicyStatement
{
 
  private String assocName = "CIM_Component";
  private String role1="GroupComponent";
  private String role2="PartComponent";
  private String auditloggerString = "";

 
  private SPLPolicy cimPolicy;
  private int priority;
  private SPLSymbolTable symTab;
  private static Logger logger = SPLLogger.getSPLLogger().getLogger();
    private static final String sourceClass="PolicyGroup";
   
   
 
  public PolicyGroup(String assocName,String role1,String role2,SPLPolicy c,String priority, SPLSymbolTable sTab)
  {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "PolicyGroup");
       
    if(!assocName.equals(""))
      this.assocName = assocName;
    if(!role1.equals(""))
      this.role1 = role1;
    if(!role2.equals(""))
      this.role2 = role2;
   
    this.cimPolicy = c;
    this.priority = Integer.parseInt(priority);
    this.symTab = sTab;
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "PolicyGroup");
       
   
  }


  public String getAssocName() {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAssocName");
       
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAssocName");
  
    return assocName;
  }


  public void setAssocName(String assocName) {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setAssocName");
       
    this.assocName = assocName;
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setAssocName");
       
  }


  public SPLPolicy getCimPolicy() {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getCimPolicy");
       
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getCimPolicy");
  
    return cimPolicy;
  }


  public void setCimPolicy(SPLPolicy cimPolicy) {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setCimPolicy");
       
    this.cimPolicy = cimPolicy;
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setCimPolicy");
       
  }


  public int getPriority() {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPriority");
       
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPriority");
  
    return priority;
  }


  public void setPriority(int priority) {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setPriority");
       
    this.priority = priority;
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setPriority");
       
  }


  public String getRole1() {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRole1");
       
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRole1");
  
    return role1;
  }


  public void setRole1(String role1) {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setRole1");
       
    this.role1 = role1;
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setRole1");
       
  }


  public String getRole2() {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getRole2");
       
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getRole2");
  
    return role2;
  }


  public void setRole2(String role2) {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "setRole2");
       
    this.role2 = role2;
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "setRole2");
       
  }
 
  public int evaluate(DataCollector dc,Actuator ac) throws SPLException {
    EvaluationResults er = evaluateForResults(dc,ac);
    return er.getStatusCode();
  }

 
  public EvaluationResults evaluateForResults(DataCollector dc,Actuator ac) throws SPLException
  {
        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
        this.auditloggerString="";
        EvaluationResults result = null;
    //System.out.println("Policy Gp::evaluate::symTab.getInstance().getCimObjectName() "+symTab.getAnchorClassList());
//    Map classToInstanceMap = null;
//    Iterator it = classToInstanceMap.keySet().iterator();
//    Object instance = null;
//    while(it.hasNext())
//    {
//      String key = (String)it.next();
//      instance = classToInstanceMap.get(key);
//    }
    String anchorClassName=(String)symTab.getAnchorClassList().get(0);
    System.out.println("-----------"+"Starting Evaluation of Policy Group"+"-----------");
   
    this.auditloggerString+="-----------"+"Starting Evaluation of Policy Group"+"-----------"+"\n";
    result = cimPolicy.evaluateForResults(dc,ac,anchorClassName,symTab.getDefaultQualifier(),symTab.getInstance(anchorClassName),assocName,role1,role2);
    this.auditloggerString+=cimPolicy.getAuditLogString();
    this.auditloggerString+="-----------"+"Completed Evaluation of Policy Group"+"-----------"+"\n";
    System.out.println("-----------"+"Completed Evaluation of Policy Group"+"-----------");
   
        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluate");
  
    return result;
  }


  public String getAuditLogString() {
   
    return this.auditloggerString;
  }
}
TOP

Related Classes of org.apache.imperius.spl.parser.statements.impl.PolicyGroup

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.