private void buildStatsPerDay(HashMap<Component, DayStats> to, HashMap<Component, List<Interval> > from){
	  Iterator componentsIterator = from.entrySet().iterator();
	  while (componentsIterator.hasNext()) {
	        Map.Entry pairs = (Map.Entry)componentsIterator.next();
                Component node = (Component)pairs.getKey();

                DayStats componentStats = to.containsKey(node)? to.get(node): new DayStats();
                HashMap<Component, DayStats> parents = new HashMap<Component, DayStats>();
                Component parent = node;
                while ((parent = parent.getParent()) != null){
                    DayStats parentStats = to.containsKey(parent)? to.get(parent): new DayStats();
                    parents.put(parent, parentStats);
                }
	        
	        /* Convert intervals to DayStats*/
	        Iterator<Interval> intervalsIterator = ((List<Interval>)pairs.getValue()).iterator();
	        while (intervalsIterator.hasNext()) {
		        Interval interval = intervalsIterator.next();
		        
		        /*Set stats for first day*/
		        Calendar calInit = interval.startTime;
		        Calendar calEnd = Calendar.getInstance();
		        Calendar calTemp = Calendar.getInstance();
		        		        		        
        		/*Set stats for other days*/
        		while(calInit.get(Calendar.DAY_OF_MONTH) < interval.endTime.get(Calendar.DAY_OF_MONTH)){
        	        
        			calTemp.clear();
        			calEnd.clear();
    		        calTemp.set(calInit.get(Calendar.YEAR), calInit.get(Calendar.MONTH), calInit.get(Calendar.DAY_OF_MONTH));  			
        			calEnd.set(calInit.get(Calendar.YEAR), calInit.get(Calendar.MONTH), calInit.get(Calendar.DAY_OF_MONTH +1));
        			
            		componentStats.add(calTemp, Time.getPeriod(calInit, calEnd));
            		calInit = calEnd;
        		}
        		
        		calTemp.clear();
        		calTemp.set(calInit.get(Calendar.YEAR), calInit.get(Calendar.MONTH), calInit.get(Calendar.DAY_OF_MONTH));
        		componentStats.add(calTemp, Time.getPeriod(calInit, interval.endTime));

                        Iterator parentsIterator = parents.entrySet().iterator();
                        while (parentsIterator.hasNext()) {
                            Map.Entry parentsPair = (Map.Entry)parentsIterator.next();
                            ((DayStats)parentsPair.getValue()).add(calTemp, Time.getPeriod(calInit, interval.endTime));
                        }
	        }

        	to.put(node, componentStats);
                Iterator parentsIterator = parents.entrySet().iterator();
                while (parentsIterator.hasNext()) {
                    Map.Entry parentsPair = (Map.Entry)parentsIterator.next();
                    to.put((Component)parentsPair.getKey(), (DayStats)parentsPair.getValue());
                }
	    }
	}