//
// https://www.ramecera.it/myscrewdriver.html
// e-mail: screwdriver@ramecera.it
//
/* 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 */
package it.ramecera.screwdriver.component;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import it.ramecera.salad.everyday.ExactException;
import it.ramecera.salad.file.Equipment;
import it.ramecera.screwdriver.CandyScrew;
import it.ramecera.screwdriver.Markup;
import it.ramecera.screwdriver.Skill;
import it.ramecera.screwdriver.Train;

/**
 * <p>
 * Class for producing the web.xml file.
 * </p>
 * 
 * @author M. Maglioni
 *         <p>
 *         Company: Ramecera™<br>
 *         Creation date: 2020-04-09<br>
 *         Last updated: 2020-04-09<br>
 *         </p>
 */
final public class Webflow_xml extends FileComponent {

	/** @param skill together with the descriptive data of the
	 * @param snippetG application */
	public Webflow_xml(Skill skill, String snippetG) {
		super();
		this.skill = skill;
		this.snippetG = snippetG;
	}

	/** sysnthesis */
	@Override
	public void synthesis(HashMap<String, Markup> markupE,
			List<Train> trainE, CandyScrew candyScrew)

			throws FileNotFoundException, IOException, ExactException {

		String webflowG = skill.candies.snippetsYS + snippetG;
		producedMaterial = Equipment.oneString(webflowG);
	}

	/** @param markupE the list of markups
	 * @throws ExactException exception specified by a numeric code */
	public void directory(HashMap<String, Markup> markupE)

			throws ExactException {

		skill.webFlowY = skill.webInfY + "/flows";
		if (skill.webFlow) {
			skill.buildDirectory(skill.webFlowY);
			/* I don't want the flow, so the webinf / flows directory
			 * needs to be cleared */
		} else if (new File(skill.webFlowY).exists()) {
			new File(skill.webFlowY).renameTo(new File(recycleBinY + "/"
					+ skill.webFlowY));
		}
	}
}
