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

package ucp.plan;

import ucp.model.*;
import ucp.parser.*;

/**
 * Class provides methods to creat ucp model, set metrics and count ucp model
 * 
 * @author Trifolium Alpestre
 */
public class UcpComputing {


    /**
     * 
     * Method creates UCP model from xml string.
     * 
     * @param xml
     * @return
     * @throws java.lang.Exception
     */
    public UcpModel createUcpModel(String xml) throws Exception //z xml ve stringu vytvori UCP model vcetne nastaveni complexity
    {
     UcpModel model;
     //vytvoreni builderu
     DocumentFromStringBuilder dfsb = new DocumentFromStringBuilder();
     //vytvoreni documentu z xml stringu a vytvoreni scanneru s documentem
     UcUML21XMI21Scanner scanner = new UcUML21XMI21Scanner(dfsb.loadXmlFromString(xml));
     //vytvoreni ucp modelu z documentu ve scanneru
     model = scanner.createUcpModel();
     
     return model;
    }


    /**
     * 
     * Method simly set up metrics for model. All elements have the same metrics.
     * 
     * @param metrics
     * @param model
     */
    public void setMetrics(UcpMetrics metrics, UcpModel model) //jednoduche nastaveni metrics - vsem elementum v modelu nastavi stejne metrics
    {
        model.setMetrics(metrics);
    }


/**
 * 
 * Method counts UCP for the model according to defined level.
 * 
 * @param model
 * @param level
 */
public void countUcp(UcpModel model, int level)
    {
        model.countUcp(level);
    }



}
