/**
 * 
 */
package eu.dnetlib.dlms.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Required;

/**
 * Class that starts the generation of System Types and Sets, using a SystemGeneration instance to be passed as
 * systemGenerator field value.
 * 
 * @author lexis
 * 
 */
public class SystemSetsGenerator {

	/**
	 * logger.
	 */
	private static final Log log = LogFactory.getLog(SystemSetsGenerator.class);
	/** generator of System Types and Sets. */
	private SystemGeneration systemGenerator;
	/** True to enable the System Sets generation, false otherwise. */
	private boolean enabled;

	/**
	 * Generates the System Sets if enabled is true. Does nothing otherwise.
	 */
	public void generateSystemSets() {
		if (this.isEnabled()) {
			log.info("GENERATING SYSTEM SETS...");
			this.systemGenerator.execute();
			log.info("GENERATION COMPLETED");
		}
	}

	public SystemGeneration getSystemGenerator() {
		return this.systemGenerator;
	}

	@Required
	public void setSystemGenerator(final SystemGeneration systemGenerator) {
		this.systemGenerator = systemGenerator;
	}

	@Required
	public void setEnabled(final boolean enable) {
		this.enabled = enable;
	}

	public boolean isEnabled() {
		return this.enabled;
	}

}
