package gov.nih.nci.codegen.transformer;

import gov.nih.nci.codegen.Artifact;
import gov.nih.nci.codegen.ArtifactHandler;
import gov.nih.nci.codegen.GenerationException;
import gov.nih.nci.codegen.GeneratorError;
import gov.nih.nci.codegen.GeneratorErrors;
import gov.nih.nci.codegen.Transformer;
import gov.nih.nci.codegen.util.TransformerUtils;
import gov.nih.nci.ncicb.xmiinout.domain.UMLClass;
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel;

import java.util.Collection;

public abstract class UMLClassJetTransformer implements Transformer
{
	private ArtifactHandler artifactHandler;

	/**
	 * @param artifactHandler the artifactHandler to set
	 */
	public void setArtifactHandler(ArtifactHandler artifactHandler)
	{
		this.artifactHandler = artifactHandler;
	}


	public GeneratorErrors execute(UMLModel model)
	{
		GeneratorErrors errors = new GeneratorErrors();
		Collection<UMLClass> classes = TransformerUtils.getAllClasses(model);
		for(UMLClass klass:classes)
			try
		{
			Artifact artifact = executeTemplate(klass);
			artifactHandler.handleArtifact(artifact);
		}
		catch(GenerationException ge)
		{
			errors.addError(new GeneratorError("Error while generating artifact for the class",ge));
		}
		return errors;
	}
	
	public abstract Artifact executeTemplate(UMLClass klass) throws GenerationException;

	public GeneratorErrors validate(UMLModel model)
	{
		// TODO Auto-generated method stub
		return null;
	}
	
}
@@ -904,25 +904,8 @@
 s = 
-TransformerUtils.
 getA
@@ -1002,16 +1002,23 @@
 emplate(
+model, 
 klass);%0A
@@ -1186,16 +1186,40 @@
 he class
+ %22+klass.getName()+%22%5Cn%5Ct
 %22,ge));%0A
@@ -1286,16 +1286,32 @@
 emplate(
+UMLModel model, 
 UMLClass
@@ -1456,9 +1456,129 @@
 l;%0A%09%7D%0A%09%0A
+%09protected Collection%3CUMLClass%3E getAllClasses(UMLModel model)%0A%09%7B%0A%09%09return TransformerUtils.getAllClasses(model);%09%09%0A%09%7D%0A%09%0A
 %7D

Generalize transformer to support any collection of classes to be processed with default beain all the classes