package cn.edu.seu.ise.dca.statistics;

import cn.edu.seu.ise.dca.util.ExcelReader;

public class ImpactCalculationAccurate {

	public static void main(String[] args) {
		String filePath = "F:\\coppermine.xls";
		ExcelReader reader = new ExcelReader(filePath);

		int startLine = 2;
		int endLine = reader.getRows();
		
		int trans = 0;
		int transRel = 0;
		int transLines = 0;
		int stru = 0;
		int struRel = 0;
		int struLines = 0;
		int ref = 0;
		int refRel = 0;
		int refLines = 0;
		int archi = 0;
		int archiRel = 0;
		int archiLines = 0;
		int qua = 0;
		int quaRel = 0;
		int quaLines = 0;
		int method = 0;
		int methodRel = 0;
		int methodLines = 0;
		
		
		while(startLine < endLine) {
			int transAtomic = Integer.parseInt(reader.read(3, startLine));
			int struAtomic = Integer.parseInt(reader.read(4, startLine));
			int refAtomic = Integer.parseInt(reader.read(5, startLine));
			int archiAtomic = Integer.parseInt(reader.read(6, startLine));
			int quaAtomic = Integer.parseInt(reader.read(7, startLine));
			int methodAtomic = Integer.parseInt(reader.read(8, startLine));
			
			int changedLines = Integer.parseInt(reader.read(12, startLine));
			
			if(transAtomic > 0 ) {
				trans ++;
				transRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				transLines += changedLines;
			}
			
			if(struAtomic > 0 ) {
				stru ++;
				struRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				struLines += changedLines;
			}
			
			if(refAtomic > 0) {
				ref ++;
				refRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				refLines += changedLines;
			}
			
			if(archiAtomic > 0) {
				archi ++;
				archiRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				archiLines += changedLines;
			}
			
			if(quaAtomic > 0) {
				qua ++;
				quaRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				quaLines += changedLines;
			}
			
			if(methodAtomic > 0) {
				method ++; 
				methodRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				methodLines += changedLines;
			}
			
			startLine ++;
			
		}
		
		System.out.println("Transformation " + trans + " " + transRel + " " + transLines);
		if(transRel != 0) 
			System.out.println("The Average is " + (double)transLines/transRel);
		
		System.out.println("Structure " + stru + " " + struRel + " " + struLines);
		if(struRel != 0) 
			System.out.println("The average is " + (double)struLines/struRel);
		
		System.out.println("Referential " + ref + " " + refRel + " " + refLines);
		if(refRel != 0) 
			System.out.println("The average is " + (double)refLines/refRel);
		
		System.out.println("Architecture " + archi + " " + archiRel + " " + archiLines);
		if(archiRel != 0) 
			System.out.println("The average is " + (double)archiLines/archiRel);
		
		System.out.println("Data Quality " + qua + " " + quaRel + " " + quaLines);
		if(quaRel != 0) 
			System.out.println("The average is " + (double)quaLines/quaRel);

		System.out.println("Method " + method + " " + methodRel + " " + methodLines);
		if(methodRel != 0) 
			System.out.println("The average is " + (double)methodLines/methodRel);
		
		
		
	}

}
