/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ucp.model;

import ucp.plan.UcpAlgorithm;

/**
 * Class represents UML Actor.
 * 
 * @author Trifolium Alpestre
 */
public class UcpActor {
    
private UcpMetrics metrics = new UcpMetrics();
private String name;
private String id;

/**
 * 
 * @return
 */
public String getName() {
        return name;
    }

    /**
     * 
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 
     * @return
     */
    public String getId() {
        return id;
    }

    /**
     * 
     * @param id
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * 
     * @return
     */
    public UcpMetrics getMetrics() {
        return metrics;
    }
    
    
     
    /**
     * Method finds elements and sets coplexity.
     * 
     * @param idref
     * @param complexity
     */
    public void setComplexity(String idref, int complexity) { //prochazi model a hleda element s idref, kteremu nastavi complexity
        
        if (id.equals(idref)) //pokud ma actor stejne id (idref)
        {
            metrics.setComplexity(complexity); //nastavi se mu complexity
        }
    }

    
    /**
     * Method sets metrics.
     * 
     * @param ucpMetrics
     */
    public void setMetrics(UcpMetrics ucpMetrics) { //jednoduche nastaveni metrics
        
        this.metrics.setT(ucpMetrics.getT()); //technical factors
        this.metrics.setE(ucpMetrics.getE()); //environmental factors
        this.metrics.setHoursPerUc(ucpMetrics.getHoursPerUc()); //normovany cas prace na jeden UC  
    }    

    
    /**
     * Method counts UCP metrics according to defined level.
     * 
     * @param level
     */
    public void countUcp(int level) //vypocet ucp
    {
        UcpAlgorithm ucpAlgorithm = new UcpAlgorithm();
        //nema sub elementy takze jen:
        //vypocet metrics pro vlastni element
        
        //level = 3 -> pocita se kazdy element
        if (level >= 3)
        {
            //vypocet metrics pro vlastni element
            ucpAlgorithm.apply(this.metrics);
        }
    }
    
}
