package org.omg.bpmn.miwg.api;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.Hashtable;
import java.util.Map;

import org.omg.bpmn.miwg.api.tools.AnalysisTool;

public class AnalysisRun {

	private AnalysisJob job;

	private Map<AnalysisTool, AnalysisResult> results = new Hashtable<AnalysisTool, AnalysisResult>();

	public AnalysisRun(AnalysisJob job) {
		this.job = job;
	}

	public void addResult(AnalysisTool tool, AnalysisResult result) {
		results.put(tool, result);
	}

	public String buildOverviewHTML(File folder)
			throws UnsupportedEncodingException {
		StringBuilder sb = new StringBuilder();

		sb.append("<div class=\"test\" ");

		for (AnalysisTool tool : results.keySet()) {
			AnalysisResult result = results.get(tool);
			assert result != null;

			sb.append(tool.getName() + "-ok=\"" + result.numOK + "\" ");
			sb.append(tool.getName() + "-finding=\"" + result.numFindings
					+ "\" ");
		}

		sb.append(">\n");
		
		sb.append("<ul>\n");

		for (AnalysisTool tool : results.keySet()) {
			AnalysisResult result = results.get(tool);
			assert result != null;

			sb.append("<li>");
			sb.append("<a href=\"" + result.getHTMLResultsLink(job) + "\">");
			sb.append(result.getResultsFileName(job));
			sb.append("</a>");
			sb.append("</li>\n");
		}

		sb.append("</ul>\n");
		
		
		sb.append("</div>\n");

		String html = sb.toString();

		return html;
	}

	public AnalysisResult getResult(String analysisToolName) {
		for (AnalysisTool tool : results.keySet()) {
			if (tool.getName().equals(analysisToolName)) {
				AnalysisResult result = results.get(tool);
				assert result != null;

				return result;
			}
		}

		return null;
	}

}

@@ -797,29 +797,48 @@
  null;%0A%0A
-%09%09%09sb.append(
+            sb.append(%22data-%22 + 
 tool.get
@@ -873,32 +873,71 @@
 umOK
- + %22%5C%22 %22);%0A%09%09%09sb.append(
+%0A                    + %22%5C%22 %22);%0A            sb.append(%22data-%22 + 
 tool
@@ -958,24 +958,44 @@
 -finding=%5C%22%22
+%0A                   
  + result.nu

Prepend non-HTML attributes with data- to ensure valid HTML whilst keeping the new naming convention