All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.drools.verifier.report.ReportModeller Maven / Gradle / Ivy

There is a newer version: 9.44.0.Final
Show newest version
package org.drools.verifier.report;

import java.util.Collection;

import org.drools.verifier.components.LiteralRestriction;
import org.drools.verifier.dao.VerifierResult;
import org.drools.verifier.report.components.Gap;
import org.drools.verifier.report.components.MissingNumberPattern;
import org.drools.verifier.report.components.Severity;
import org.drools.verifier.report.components.VerifierMessage;
import org.drools.verifier.report.components.VerifierMessageBase;

import com.thoughtworks.xstream.XStream;

/**
 *
 * @author Toni Rikkola
 */
public class ReportModeller {

	public static String writeXML(VerifierResult result) {
		XStream xstream = new XStream();

		xstream.alias("result", VerifierResult.class);
		xstream.alias("message", VerifierMessage.class);

		xstream.alias("Gap", Gap.class);
		xstream.alias("MissingNumber", MissingNumberPattern.class);

		xstream.alias("Field", org.drools.verifier.components.Field.class);

		xstream.alias("LiteralRestriction", LiteralRestriction.class);

		return "\n" + xstream.toXML(result);
	}

	public static String writePlainText(VerifierResult result) {

		StringBuffer str = new StringBuffer();

		for (Severity severity : Severity
				.values()) {
			Collection messages = result
					.getBySeverity(severity);

			str.append("************* ");
			str.append(severity.getTuple());
			str.append(" ");

			str.append(messages.size());
			str.append(" ******************\n");
			for (VerifierMessageBase message : messages) {
				str.append(message);
				str.append("\n");
			}
			str.append("\n");
		}

		return str.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy