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

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

public class ImpactCalculationRough {

	public static void main(String[] args) {
		String filePath = "F:\\Temp\\all_impact\\weberp.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(11, startLine));
			
			if(transAtomic > 0 && struAtomic ==0 && refAtomic == 0 && archiAtomic == 0  && methodAtomic == 0) {
				trans ++;
				//transRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				transLines += changedLines;
			}
			
			if(struAtomic > 0 && transAtomic ==0 && refAtomic == 0 && archiAtomic == 0 && methodAtomic == 0) {
				stru ++;
				//struRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				struLines += changedLines;
			}
			
			if(refAtomic > 0 && struAtomic ==0 && transAtomic == 0 && archiAtomic == 0 && quaAtomic == 0 && methodAtomic == 0 ) {
				ref ++;
				//refRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				refLines += changedLines;
			}
			
			if(archiAtomic > 0 && struAtomic ==0 && refAtomic == 0 && transAtomic == 0 && quaAtomic == 0 && methodAtomic == 0 ) {
				archi ++;
				//archiRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				archiLines += changedLines;
			}
			
			if(quaAtomic > 0 && struAtomic ==0 && refAtomic == 0 && archiAtomic == 0 && transAtomic == 0 && methodAtomic == 0 ) {
				qua ++;
				//quaRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				quaLines += changedLines;
			}
			
			if(methodAtomic > 0 && struAtomic ==0 && refAtomic == 0 && archiAtomic == 0  && quaAtomic == 0 && transAtomic == 0) {
				method ++; 
				//methodRel += transAtomic + struAtomic + refAtomic + archiAtomic + quaAtomic + methodAtomic;
				methodLines += changedLines;
			}
			
			startLine ++;
			
		}
		
		System.out.println("Transformation " + trans + " " + transLines);
		if(trans != 0) 
			System.out.println("The Average is " + (double)transLines/trans);
		
		System.out.println("Structure " + stru + " " + struLines);
		if(stru != 0) 
			System.out.println("The average is " + (double)struLines/stru);
		
		System.out.println("Referential " + ref + " " + refLines);
		if(ref != 0) 
			System.out.println("The average is " + (double)refLines/ref);
		
		System.out.println("Architecture " + archi + " " + archiLines);
		if(archi != 0) 
			System.out.println("The average is " + (double)archiLines/archi);
		
		System.out.println("Data Quality " + qua + " " + quaLines);
		if(qua != 0) 
			System.out.println("The average is " + (double)quaLines/qua);

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

}
