<commit_before>/*******************************************************************************
 * Copyright (c) 2013, 2014- UT-Battelle, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Initial API and implementation and/or initial documentation - <NAME>,
 *   <NAME>, <NAME>, <NAME>, <NAME>,
 *   <NAME>, <NAME>, <NAME>
 *******************************************************************************/
package org.eclipse.ice.item.nuclear;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Stack;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite;
import org.eclipse.ice.datastructures.form.AllowedValueType;
import org.eclipse.ice.datastructures.form.DataComponent;
import org.eclipse.ice.datastructures.form.Entry;
import org.eclipse.ice.datastructures.form.Form;
import org.eclipse.ice.datastructures.form.FormStatus;
import org.eclipse.ice.datastructures.form.ResourceComponent;
import org.eclipse.ice.datastructures.form.TreeComposite;
import org.eclipse.ice.datastructures.resource.ICEResource;
import org.eclipse.ice.io.serializable.IReader;
import org.eclipse.ice.io.serializable.IWriter;
import org.eclipse.ice.item.Item;
import org.eclipse.ice.item.ItemType;

/**
 * An MOOSE Item for creating MOOSE input files. This Item expects to find the
 * YAML and action syntax files necessary in the ${workspace}/MOOSE directory.
 * These files can be generated automatically using the ICE YAML/action syntax
 * generator, or manually at the command line with the command(s):
 * 
 * ./{moose-app}-opt --yaml > {moose-app}.yaml <br>
 * ./{moose-app}-opt --syntax > {moose-app}.syntax
 * 
 * These lines must be executed for each MOOSE-based code to be used by ICE.
 * This class' Item builder defaults the MOOSE-based application to null,
 * forcing the user to select the app. Once an app is selected, reviewEntries()
 * is triggered and loads the YAML spec. If the Item was imported from an input
 * file, any data from the input file is consolidated with the YAML file in the
 * reviewEntries() method as well.
 * 
 * The MOOSEModel Form has components with set IDs as such:
 * 
 * ID = 1: The output file DataComponent ID = 2: The TreeComposite containing
 * MOOSE data ID = 3: The ResourceComponent (for displaying mesh files as
 * ICEResources)
 *
 * It is not, in general, necessary to subclass this Item and all
 * reconfiguration can be done by the builder by setting the executable name
 * since the only thing that changes from application to application is the YAML
 * input file.
 * 
 * @author <NAME>, <NAME>, <NAME>
 */

@XmlRootElement(name = "MOOSEModel")
public class MOOSEModel extends Item {

	/**
	 * The ID of the DataComponent containing the output file name.
	 */
	@XmlTransient
	public static final int fileDataComponentId = 1;

	/**
	 * The ID of the TreeComposite containing the MOOSE input tree. tree.
	 */
	@XmlTransient
	public static final int mooseTreeCompositeId = 2;

	/**
	 * The ID of the ResourceComponent that holds the mesh ICEResource.
	 */
	@XmlTransient
	public static final int resourceComponentId = 3;

	/**
	 * The process tag for writing the MOOSE output file.
	 */
	@XmlTransient
	protected static final String mooseProcessActionString = "Write MOOSE File";

	/**
	 * The list of MOOSE applications available for this Model.
	 */
	@XmlTransient
	protected ArrayList<String> mooseApps;

	/**
	 * The currently loaded MOOSE-based application.
	 */
	@XmlTransient
	protected String loadedApp;

	/**
	 * The name of the file currently stored on the Form's ResourceComponent.
	 */
	@XmlTransient
	protected String meshFileName;

	/**
	 * An ArrayList of TreeComposites, constructed from the top-level children
	 * of the YAML spec (ie. children directly beneath the root). Used for easy
	 * cross-reference across multiple methods.
	 */
	@XmlTransient
	private ArrayList<TreeComposite> topLevelYamlTrees = null;

	/**
	 * An ArrayList of TreeComposites, constructed from the top-level children
	 * of the input data (ie. children directly beneath the root). Used for easy
	 * cross-reference across multiple methods.
	 */
	@XmlTransient
	private ArrayList<TreeComposite> topLevelInputTrees = null;

	/**
	 * Nullary constructor.
	 */
	public MOOSEModel() {
		this(null);
		return;
	}

	/**
	 * The constructor with a project space in which files should be
	 * manipulated.
	 * 
	 * @param projectSpace
	 *            The Eclipse project where files should be stored and from
	 *            which they should be retrieved.
	 */
	public MOOSEModel(IProject projectSpace) {
		// Call super
		super(projectSpace);
		return;
	}

	/**
	 * This operation creates the MOOSE input file.
	 * 
	 * @param actionName
	 *            The name of action that should be performed using the
	 *            processed Form data.
	 * @return The status of the Item after processing the Form and executing
	 *         the action. It returns FormStatus.InfoError if it is unable to
	 *         run for any reason, including being asked to run actions that are
	 *         not in the list of available actions.
	 */
	public FormStatus process(String actionName) {

		// Local Declarations
		FormStatus retStatus = FormStatus.InfoError;
		Entry outputFileEntry = ((DataComponent) form
				.getComponent(fileDataComponentId))
				.retrieveEntry("Output File Name");
		String outputFilename = outputFileEntry.getValue();
		IWriter writer = getWriter();

		// Check that the process is something that we will do and that the Item
		// is enabled
		if (mooseProcessActionString.equals(actionName) && isEnabled()
				&& writer != null) {
			// Get the file location
			IFile outputFile = project.getFile(outputFilename);

			// Write the Moose tree to file
			writer.write(form, outputFile);

			// Refresh the Project space
			refreshProjectSpace();

			// Update the status
			retStatus = FormStatus.Processed;
		} else {
			// Otherwise, punt it up to the parent to see if it can handle it.
			retStatus = super.process(actionName);
		}

		// Reset the status and return. It should only be updated if the Item is
		// enabled.
		if (isEnabled()) {
			status = retStatus;
			return retStatus;
		} else {
			return FormStatus.Unacceptable;
		}
	}

	/**
	 * This operation sets up the Form for the MOOSEModel. The form is designed
	 * to contain 3 Components.
	 * 
	 * The Form component with ID=1 is a DataComponent containing Entries
	 * related to which MOOSE-based codes are available, as well as the output
	 * file created from the MOOSE Model. These Entries in the DataComponent are
	 * named "MOOSE-Based Application" with ID=1 and "Output File Name" with
	 * ID=2.
	 * 
	 * The Form component with ID=2 is a TreeComposite containing the structure
	 * of the MOOSE input tree. By default, this Tree is empty until blocks are
	 * added to it by the user.
	 * 
	 * The Form component with ID=3 is the ResourceComponent which can store
	 * ICEResources on it. This is intended to be used for problems with mesh
	 * files which can be rendered through a VizResource publisher.
	 */
	protected void setupForm() {

		// Local Declarations
		Entry mooseAppEntry;

		// Create the Form
		form = new Form();

		// Create the DataComponent and add it
		DataComponent fileDataComponent = new DataComponent();
		fileDataComponent.setId(fileDataComponentId);
		fileDataComponent.setName("Output File Parameters");
		fileDataComponent.setDescription("Global parameters for the output "
				+ "file that ICE will create.");
		form.addComponent(fileDataComponent);

		// Create the ResourceComponent and add it
		ResourceComponent resourceComponent = new ResourceComponent();
		resourceComponent.setName("Mesh");
		resourceComponent.setId(3);
		resourceComponent.setDescription("File resources associated "
				+ "to this MOOSE Model.");
		form.addComponent(resourceComponent);

		// Add the default dummy text to the list of available apps
		mooseApps = new ArrayList<String>();

		// Get the list of MOOSE configuration files available to ICE, if
		// possible, before creating the app Entry.
		if (project != null && project.isAccessible()) {
			// Get the MOOSE folder
			IFolder mooseFolder = project.getFolder("MOOSE");
			// Get the files from it if it exists
			if (mooseFolder.exists()) {
				try {
					IResource[] resources = mooseFolder.members();
					// Check the resources and retrieve the .yaml files
					for (IResource resource : resources) {
						if (resource.getType() == IResource.FILE
								&& resource.getProjectRelativePath()
										.lastSegment().contains(".yaml")) {
							String[] splitName = resource.getName()
									.split("\\.");
							// Only add the app name, not the file extension
							mooseApps.add(splitName[0]);
						}
					}
				} catch (CoreException e) {
					// Complain
					e.printStackTrace();
				}
			}
		}

		// Only load up the Entry if some MOOSE apps were discovered.
		if (!mooseApps.isEmpty()) {
			// Set the default as null, which will default to "MOOSE app..."
			// from the Entry's list of allowed values when Entry.getValue() is
			// called. This is done intentionally to force the user to select an
			// app when importing an Item
			loadedApp = null;
			// Create the MOOSE application Entry. Add all of the files if any
			// were found.
			mooseAppEntry = new Entry() {
				protected void setup() {
					allowedValues = mooseApps;
					allowedValueType = AllowedValueType.Discrete;
					defaultValue = loadedApp;
				}
			};
		} else {
			mooseAppEntry = new Entry() {
				protected void setup() {
					defaultValue = "No MOOSE apps were found.";
				}
			};
		}
		mooseAppEntry.setId(1);
		mooseAppEntry.setName("MOOSE-Based Application");
		mooseAppEntry.setDescription("The name of the MOOSE-based application "
				+ "for which you would like to create an input file.");
		// Add it to the DataComponent
		fileDataComponent.addEntry(mooseAppEntry);

		// Create the output file Entry on the form
		Entry outputFileEntry = new Entry() {
			protected void setup() {
				defaultValue = "mooseModel.i";
			}
		};
		outputFileEntry.setId(2);
		outputFileEntry.setName("Output File Name");
		outputFileEntry.setDescription("The file name of the output file, "
				+ "including extension.");
		// Add it to the DataComponent
		fileDataComponent.addEntry(outputFileEntry);

		// Create the TreeComposite on the form
		TreeComposite mooseDataTree = new TreeComposite();
		mooseDataTree.setId(mooseTreeCompositeId);
		mooseDataTree
				.setDescription("The tree of input data for this problem.");
		mooseDataTree.setName("Input Data");
		form.addComponent(mooseDataTree);

		return;
	}

	/**
	 * This operation is used to setup the name and description of the model.
	 */
	protected void setupItemInfo() {

		// Local Declarations
		String desc = "This item builds models for "
				+ "MOOSE-based applications for "
				+ "nuclear energy modeling and simulation.";

		// Describe the Item
		setName("MOOSE Model Builder");
		setDescription(desc);
		itemType = ItemType.Model;

		// Setup the action list. Remove key-value pair support.
		allowedActions.remove(taggedExportActionString);
		// Add MOOSE GetPot export action
		allowedActions.add(0, mooseProcessActionString);

		return;
	}

	/**
	 * This operation loads the contents of the TreeComposite from the MOOSE
	 * data. It is called when a MOOSE-based application has been accepted and
	 * the entries are reviewed. It will only load the Form if the project space
	 * exists - so that it can find the files - and if the Form has been
	 * previously configured. It compares the executable name passed to this
	 * function with the files in the project directory and looks for a match
	 * with the name "executuableName.yaml" that it can load. It throws an
	 * IOException if it cannot find a match.
	 * 
	 * @param mooseExecutableName
	 *            The name of the MOOSE executable whose YAML input
	 *            specification should be loaded into the Form's TreeComposite.
	 * @throws IOException
	 * @throws CoreException
	 */
	protected void loadTreeContents(String mooseExecutableName)
			throws IOException, CoreException {

		// Local Declarations
		TreeComposite mooseParentTree = (TreeComposite) form
				.getComponent(mooseTreeCompositeId), tmpParentTree;

		// Load the file from the project space if possible
		if (project != null && project.isAccessible()) {

			// Get the MOOSE folder
			IFolder mooseFolder = project.getFolder("MOOSE");

			// If the MOOSE folder doesn't exist, create it and complain
			if (!mooseFolder.exists()) {
				mooseFolder.create(true, true, null);
				throw new IOException("MOOSEModel Exception: "
						+ "MOOSE directory is empty. Run YAML/action syntax "
						+ "generator to populate with necessary data.");
			}

			// Get the file
			IFile modelFile = mooseFolder
					.getFile(mooseExecutableName + ".yaml");<commit_msg>Changed the MOOSE Model Builder's MOOSE apps to be upper case. This required me to update a few lines in the MOOSE Model, specifically to convert the YAML file names (which are fed to the MMB) to upper case, and then back to lower case when the YAML file must be determined from the app name. The apps in the MOOSE Model Builder now match the MOOSE Launcher.<commit_after>/*******************************************************************************
 * Copyright (c) 2013, 2014- UT-Battelle, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Initial API and implementation and/or initial documentation - <NAME>,
 *   <NAME>, <NAME>, <NAME>, <NAME>,
 *   <NAME>, <NAME>, <NAME>
 *******************************************************************************/
package org.eclipse.ice.item.nuclear;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Stack;

import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ice.datastructures.ICEObject.Component;
import org.eclipse.ice.datastructures.ICEObject.IUpdateable;
import org.eclipse.ice.datastructures.form.AdaptiveTreeComposite;
import org.eclipse.ice.datastructures.form.AllowedValueType;
import org.eclipse.ice.datastructures.form.DataComponent;
import org.eclipse.ice.datastructures.form.Entry;
import org.eclipse.ice.datastructures.form.Form;
import org.eclipse.ice.datastructures.form.FormStatus;
import org.eclipse.ice.datastructures.form.ResourceComponent;
import org.eclipse.ice.datastructures.form.TreeComposite;
import org.eclipse.ice.datastructures.resource.ICEResource;
import org.eclipse.ice.io.serializable.IReader;
import org.eclipse.ice.io.serializable.IWriter;
import org.eclipse.ice.item.Item;
import org.eclipse.ice.item.ItemType;

/**
 * An MOOSE Item for creating MOOSE input files. This Item expects to find the
 * YAML and action syntax files necessary in the ${workspace}/MOOSE directory.
 * These files can be generated automatically using the ICE YAML/action syntax
 * generator, or manually at the command line with the command(s):
 * 
 * ./{moose-app}-opt --yaml > {moose-app}.yaml <br>
 * ./{moose-app}-opt --syntax > {moose-app}.syntax
 * 
 * These lines must be executed for each MOOSE-based code to be used by ICE.
 * This class' Item builder defaults the MOOSE-based application to null,
 * forcing the user to select the app. Once an app is selected, reviewEntries()
 * is triggered and loads the YAML spec. If the Item was imported from an input
 * file, any data from the input file is consolidated with the YAML file in the
 * reviewEntries() method as well.
 * 
 * The MOOSEModel Form has components with set IDs as such:
 * 
 * ID = 1: The output file DataComponent ID = 2: The TreeComposite containing
 * MOOSE data ID = 3: The ResourceComponent (for displaying mesh files as
 * ICEResources)
 *
 * It is not, in general, necessary to subclass this Item and all
 * reconfiguration can be done by the builder by setting the executable name
 * since the only thing that changes from application to application is the YAML
 * input file.
 * 
 * @author <NAME>, <NAME>, <NAME>key
 */

@XmlRootElement(name = "MOOSEModel")
public class MOOSEModel extends Item {

	/**
	 * The ID of the DataComponent containing the output file name.
	 */
	@XmlTransient
	public static final int fileDataComponentId = 1;

	/**
	 * The ID of the TreeComposite containing the MOOSE input tree. tree.
	 */
	@XmlTransient
	public static final int mooseTreeCompositeId = 2;

	/**
	 * The ID of the ResourceComponent that holds the mesh ICEResource.
	 */
	@XmlTransient
	public static final int resourceComponentId = 3;

	/**
	 * The process tag for writing the MOOSE output file.
	 */
	@XmlTransient
	protected static final String mooseProcessActionString = "Write MOOSE File";

	/**
	 * The list of MOOSE applications available for this Model.
	 */
	@XmlTransient
	protected ArrayList<String> mooseApps;

	/**
	 * The currently loaded MOOSE-based application.
	 */
	@XmlTransient
	protected String loadedApp;

	/**
	 * The name of the file currently stored on the Form's ResourceComponent.
	 */
	@XmlTransient
	protected String meshFileName;

	/**
	 * An ArrayList of TreeComposites, constructed from the top-level children
	 * of the YAML spec (ie. children directly beneath the root). Used for easy
	 * cross-reference across multiple methods.
	 */
	@XmlTransient
	private ArrayList<TreeComposite> topLevelYamlTrees = null;

	/**
	 * An ArrayList of TreeComposites, constructed from the top-level children
	 * of the input data (ie. children directly beneath the root). Used for easy
	 * cross-reference across multiple methods.
	 */
	@XmlTransient
	private ArrayList<TreeComposite> topLevelInputTrees = null;

	/**
	 * Nullary constructor.
	 */
	public MOOSEModel() {
		this(null);
		return;
	}

	/**
	 * The constructor with a project space in which files should be
	 * manipulated.
	 * 
	 * @param projectSpace
	 *            The Eclipse project where files should be stored and from
	 *            which they should be retrieved.
	 */
	public MOOSEModel(IProject projectSpace) {
		// Call super
		super(projectSpace);
		return;
	}

	/**
	 * This operation creates the MOOSE input file.
	 * 
	 * @param actionName
	 *            The name of action that should be performed using the
	 *            processed Form data.
	 * @return The status of the Item after processing the Form and executing
	 *         the action. It returns FormStatus.InfoError if it is unable to
	 *         run for any reason, including being asked to run actions that are
	 *         not in the list of available actions.
	 */
	public FormStatus process(String actionName) {

		// Local Declarations
		FormStatus retStatus = FormStatus.InfoError;
		Entry outputFileEntry = ((DataComponent) form
				.getComponent(fileDataComponentId))
				.retrieveEntry("Output File Name");
		String outputFilename = outputFileEntry.getValue();
		IWriter writer = getWriter();

		// Check that the process is something that we will do and that the Item
		// is enabled
		if (mooseProcessActionString.equals(actionName) && isEnabled()
				&& writer != null) {
			// Get the file location
			IFile outputFile = project.getFile(outputFilename);

			// Write the Moose tree to file
			writer.write(form, outputFile);

			// Refresh the Project space
			refreshProjectSpace();

			// Update the status
			retStatus = FormStatus.Processed;
		} else {
			// Otherwise, punt it up to the parent to see if it can handle it.
			retStatus = super.process(actionName);
		}

		// Reset the status and return. It should only be updated if the Item is
		// enabled.
		if (isEnabled()) {
			status = retStatus;
			return retStatus;
		} else {
			return FormStatus.Unacceptable;
		}
	}

	/**
	 * This operation sets up the Form for the MOOSEModel. The form is designed
	 * to contain 3 Components.
	 * 
	 * The Form component with ID=1 is a DataComponent containing Entries
	 * related to which MOOSE-based codes are available, as well as the output
	 * file created from the MOOSE Model. These Entries in the DataComponent are
	 * named "MOOSE-Based Application" with ID=1 and "Output File Name" with
	 * ID=2.
	 * 
	 * The Form component with ID=2 is a TreeComposite containing the structure
	 * of the MOOSE input tree. By default, this Tree is empty until blocks are
	 * added to it by the user.
	 * 
	 * The Form component with ID=3 is the ResourceComponent which can store
	 * ICEResources on it. This is intended to be used for problems with mesh
	 * files which can be rendered through a VizResource publisher.
	 */
	protected void setupForm() {

		// Local Declarations
		Entry mooseAppEntry;

		// Create the Form
		form = new Form();

		// Create the DataComponent and add it
		DataComponent fileDataComponent = new DataComponent();
		fileDataComponent.setId(fileDataComponentId);
		fileDataComponent.setName("Output File Parameters");
		fileDataComponent.setDescription("Global parameters for the output "
				+ "file that ICE will create.");
		form.addComponent(fileDataComponent);

		// Create the ResourceComponent and add it
		ResourceComponent resourceComponent = new ResourceComponent();
		resourceComponent.setName("Mesh");
		resourceComponent.setId(3);
		resourceComponent.setDescription("File resources associated "
				+ "to this MOOSE Model.");
		form.addComponent(resourceComponent);

		// Add the default dummy text to the list of available apps
		mooseApps = new ArrayList<String>();

		// Get the list of MOOSE configuration files available to ICE, if
		// possible, before creating the app Entry.
		if (project != null && project.isAccessible()) {
			// Get the MOOSE folder
			IFolder mooseFolder = project.getFolder("MOOSE");
			// Get the files from it if it exists
			if (mooseFolder.exists()) {
				try {
					IResource[] resources = mooseFolder.members();
					// Check the resources and retrieve the .yaml files
					for (IResource resource : resources) {
						if (resource.getType() == IResource.FILE
								&& resource.getProjectRelativePath()
										.lastSegment().contains(".yaml")) {
							String[] splitName = resource.getName()
									.split("\\.");
							// Only add the app name, not the file extension.
							// Use upper case for consistency with the MOOSE
							// Launcher, also since the app names are acronyms.
							mooseApps.add(splitName[0].toUpperCase());
						}
					}
				} catch (CoreException e) {
					// Complain
					e.printStackTrace();
				}
			}
		}

		// Only load up the Entry if some MOOSE apps were discovered.
		if (!mooseApps.isEmpty()) {
			// Set the default as null, which will default to "MOOSE app..."
			// from the Entry's list of allowed values when Entry.getValue() is
			// called. This is done intentionally to force the user to select an
			// app when importing an Item
			loadedApp = null;
			// Create the MOOSE application Entry. Add all of the files if any
			// were found.
			mooseAppEntry = new Entry() {
				protected void setup() {
					allowedValues = mooseApps;
					allowedValueType = AllowedValueType.Discrete;
					defaultValue = loadedApp;
				}
			};
		} else {
			mooseAppEntry = new Entry() {
				protected void setup() {
					defaultValue = "No MOOSE apps were found.";
				}
			};
		}
		mooseAppEntry.setId(1);
		mooseAppEntry.setName("MOOSE-Based Application");
		mooseAppEntry.setDescription("The name of the MOOSE-based application "
				+ "for which you would like to create an input file.");
		// Add it to the DataComponent
		fileDataComponent.addEntry(mooseAppEntry);

		// Create the output file Entry on the form
		Entry outputFileEntry = new Entry() {
			protected void setup() {
				defaultValue = "mooseModel.i";
			}
		};
		outputFileEntry.setId(2);
		outputFileEntry.setName("Output File Name");
		outputFileEntry.setDescription("The file name of the output file, "
				+ "including extension.");
		// Add it to the DataComponent
		fileDataComponent.addEntry(outputFileEntry);

		// Create the TreeComposite on the form
		TreeComposite mooseDataTree = new TreeComposite();
		mooseDataTree.setId(mooseTreeCompositeId);
		mooseDataTree
				.setDescription("The tree of input data for this problem.");
		mooseDataTree.setName("Input Data");
		form.addComponent(mooseDataTree);

		return;
	}

	/**
	 * This operation is used to setup the name and description of the model.
	 */
	protected void setupItemInfo() {

		// Local Declarations
		String desc = "This item builds models for "
				+ "MOOSE-based applications for "
				+ "nuclear energy modeling and simulation.";

		// Describe the Item
		setName("MOOSE Model Builder");
		setDescription(desc);
		itemType = ItemType.Model;

		// Setup the action list. Remove key-value pair support.
		allowedActions.remove(taggedExportActionString);
		// Add MOOSE GetPot export action
		allowedActions.add(0, mooseProcessActionString);

		return;
	}

	/**
	 * This operation loads the contents of the TreeComposite from the MOOSE
	 * data. It is called when a MOOSE-based application has been accepted and
	 * the entries are reviewed. It will only load the Form if the project space
	 * exists - so that it can find the files - and if the Form has been
	 * previously configured. It compares the executable name passed to this
	 * function with the files in the project directory and looks for a match
	 * with the name "executuableName.yaml" that it can load. It throws an
	 * IOException if it cannot find a match.
	 * 
	 * @param mooseExecutableName
	 *            The name of the MOOSE executable whose YAML input
	 *            specification should be loaded into the Form's TreeComposite.
	 * @throws IOException
	 * @throws CoreException
	 */
	protected void loadTreeContents(String mooseExecutableName)
			throws IOException, CoreException {

		// Local Declarations
		TreeComposite mooseParentTree = (TreeComposite) form
				.getComponent(mooseTreeCompositeId), tmpParentTree;

		// Load the file from the project space if possible
		if (project != null && project.isAccessible()) {

			// Get the MOOSE folder
			IFolder mooseFolder = project.getFolder("MOOSE");

			// If the MOOSE folder doesn't exist, create it and complain
			if (!mooseFolder.exists()) {
				mooseFolder.create(true, true, null);
				throw new IOException("MOOSEModel Exception: "
						+ "MOOSE directory is empty. Run YAML/action syntax "
						+ "generator to populate with necessary data.");
			}

			// Get the file. We must convert to lower case to match the YAML
			// files.
			IFile modelFile = mooseFolder.getFile(mooseExecutableName
					.toLowerCase() + ".yaml");
{'fraction_non_alphanumeric': 0.09717021889400922, 'fraction_numerical': 0.0020881336405529955, 'mean_word_length': 3.5416939175931983, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2771571', 'n_tokens_mistral': 8607, 'n_tokens_neox': 7538, 'n_words': 2905}