// - now place the collections of elements by the given variable names.
// (skip if the variable is NOT defined)
for (final Iterator iterator = modelElements.getModelElements().iterator(); iterator.hasNext();)
{
final ModelElement modelElement = (ModelElement)iterator.next();
final String modelElementVariable = modelElement.getVariable();
if (modelElementVariable != null && modelElementVariable.trim().length() > 0)
{
// - if a modelElement has the same variable defined
// more than one time, then get the existing
// model elements added from the last iteration
// and add the new ones to that collection
Collection metafacades = (Collection)templateContext.get(modelElementVariable);
if (metafacades != null)
{
metafacades.addAll(modelElement.getMetafacades());
}
else
{
metafacades = modelElement.getMetafacades();
templateContext.put(
modelElementVariable,
new LinkedHashSet(metafacades));
}
}
}
this.processWithTemplate(
template,
templateContext,
null,
null);
}
else
{
// - if outputToSingleFile isn't true, then
// we just place the model element with the default
// variable defined on the <modelElements/> into the
// template.
for (final Iterator iterator = allMetafacades.iterator(); iterator.hasNext();)
{
final Map templateContext = new LinkedHashMap();
final Object metafacade = iterator.next();
final ModelAccessFacade model = factory.getModel();
for (final Iterator elements = modelElements.getModelElements().iterator(); elements.hasNext();)
{
final ModelElement modelElement = (ModelElement)elements.next();
String variable = modelElement.getVariable();
// - if the variable isn't defined on the <modelElement/>, try
// the <modelElements/>
if (variable == null || variable.trim().length() == 0)
{