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

package ucp.plan;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import ucp.model.UcpMetrics;
import ucp.model.UcpModel;
import ucp.ws.Model2Elements;
import ucp.ws.UcpElement;


/**
 *
 * @author Trifolium Alpestre
 */
public class Test {
    
private static UcpMetrics metrics = new UcpMetrics();
private static int[] ef = {3,3,3,3,3,3,3,3};
private static int[] tf = {3,3,3,3,3,3,3,3,3,3,3,3,3};
    
    
/**
 * 
 * @param args
 * @throws java.lang.Exception
 */
public static void main(String[] args) throws Exception
{
  System.out.println("UCP MODEL:");
  String xml = "";

  metrics.setE(ef);
  metrics.setT(tf);
 
  metrics.setHoursPerUc(25);
  
  
  StringBuffer fileData = new StringBuffer(1000);
  BufferedReader reader = new BufferedReader(new FileReader("D://DATA/export.xml"));
  char[] buf = new char[1024];
  int numRead=0;
  while((numRead=reader.read(buf)) != -1)
   {
       fileData.append(buf, 0, numRead);
   }
  reader.close();
        
  xml = fileData.toString();
  
  UcpModel model;
  ArrayList<UcpElement> eList;
  UcpComputing ucpComputing = new UcpComputing();
  Model2Elements m2e = new Model2Elements();
        
  model = ucpComputing.createUcpModel(xml); //z xml stringu udelat ucp model
  ucpComputing.setMetrics(metrics, model); //jednoduche nastaveni metrics vsem elementum modelu
  ucpComputing.countUcp(model, 0);//vypocet ucp u modelu, nastaven level vypoctu
  eList = m2e.transform(model); //z ucp modelu udelat kolekci elementu pro WS
  
  for (UcpElement e:eList)
     {
      System.out.println("-------------");
      System.out.println(e.getIdParent());
      System.out.println(e.getId());
      System.out.println(e.getType());
      System.out.println(e.getComplexity());
      System.out.println(e.getSubUUCP());
      
      System.out.println(e.getUcp());
      System.out.println(e.getSubUCP());

      System.out.println(e.getHoursPerUc());
      System.out.println(e.getSchneiderwinters());
      
      System.out.println(e.getHours());
      System.out.println(e.getHoursSW());
      System.out.println(e.getSubCasesHours());
      System.out.println(e.getSubCasesHoursSW());

     }
  }
  
}
