// Path: src/main/java/org/openstreetmap/osmaxil/Application.java
// @Component("OsmaxilApp")
// public class Application {
// 
// 	@Value("${osmaxil.flow}")
// 	public String flow;
// 	
// 	public static final String NAME = "Osmaxil";
// 
// 	private static ClassPathXmlApplicationContext applicationContext;
// 
// 	static private final Logger LOGGER = Logger.getLogger(Application.class);
// 
// 	static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats");
// 
// 	public static void main(String[] args) {
// 		applicationContext = new ClassPathXmlApplicationContext("spring.xml");
// 		Application app = (Application) applicationContext.getBean("OsmaxilApp");
// 		LOGGER.info("=== Starting Osmaxil ===");
// 		long startTime = System.currentTimeMillis();
// 		try {
// 			app.run();
// 		} catch (Exception e) {
// 			LOGGER.error(e);
// 		}
// 		LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds");
// 		LOGGER.info("=== Osmaxil has finished its job ===");
// 		applicationContext.close();
// 	}
// 	
// 	public void run() throws Exception {
// 		__AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow);
// 		flow.load();
// 		flow.process();
// 		flow.synchronize();
// 		flow.displayLoadingStatistics();
// 		flow.displayProcessingStatistics();
// 	}
// }
// 
// Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java
// @XmlRootElement(name = "osm")
// public class OsmXmlRoot {
// 
// 	@XmlAttribute
// 	public float version;
// 
// 	@XmlAttribute
// 	public String generator;
// 
// 	@XmlElement(name = "node")
// 	public List<OsmXmlNode> nodes = new ArrayList<>();;
// 
// 	@XmlElement(name = "way")
// 	public List<OsmXmlWay> ways = new ArrayList<>();;
// 
// 	@XmlElement(name = "relations")
// 	public List<OsmXmlRelation> relations = new ArrayList<>();
// 
// }


import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.annotation.PreDestroy;
import javax.xml.transform.stream.StreamResult;
import org.apache.log4j.Logger;
import org.openstreetmap.osmaxil.Application;
import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.oxm.Marshaller;
import org.springframework.stereotype.Repository;

package org.openstreetmap.osmaxil.dao;




@Repository
public class OsmXmlFile {

	@Autowired
	@Qualifier(value = "osmMarshaller")
	private Marshaller marshaller;

	private int counterForWriteSuccess;

	private int counterForWriteFailures;

	static private final Logger LOGGER = Logger.getLogger(Application.class);

	static private final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats");

	static private final String GEN_DIR = "gen";

	@PreDestroy
	public void close() {
		LOGGER_FOR_STATS.info("=== Closing OSM XML service ===");
		LOGGER_FOR_STATS.info("Total of writing successes: " + this.counterForWriteSuccess);
		LOGGER_FOR_STATS.info("Total of writing failures: " + this.counterForWriteFailures);
	}

	public boolean writeToFile(String name, OsmXmlRoot root) {
		boolean result = false;
		String fileName = null;
		FileOutputStream os = null;
		try {
			root.version = 0.6f;

// Path: src/main/java/org/openstreetmap/osmaxil/Application.java
// @Component("OsmaxilApp")
// public class Application {
// 
// 	@Value("${osmaxil.flow}")
// 	public String flow;
// 	
// 	public static final String NAME = "Osmaxil";
// 
// 	private static ClassPathXmlApplicationContext applicationContext;
// 
// 	static private final Logger LOGGER = Logger.getLogger(Application.class);
// 
// 	static protected final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats");
// 
// 	public static void main(String[] args) {
// 		applicationContext = new ClassPathXmlApplicationContext("spring.xml");
// 		Application app = (Application) applicationContext.getBean("OsmaxilApp");
// 		LOGGER.info("=== Starting Osmaxil ===");
// 		long startTime = System.currentTimeMillis();
// 		try {
// 			app.run();
// 		} catch (Exception e) {
// 			LOGGER.error(e);
// 		}
// 		LOGGER_FOR_STATS.info("Job has been executed in " + (System.currentTimeMillis() - startTime) / 1000 + " seconds");
// 		LOGGER.info("=== Osmaxil has finished its job ===");
// 		applicationContext.close();
// 	}
// 	
// 	public void run() throws Exception {
// 		__AbstractImportFlow<?, ?> flow = (__AbstractImportFlow<?, ?>) applicationContext.getBean(this.flow);
// 		flow.load();
// 		flow.process();
// 		flow.synchronize();
// 		flow.displayLoadingStatistics();
// 		flow.displayProcessingStatistics();
// 	}
// }
// 
// Path: src/main/java/org/openstreetmap/osmaxil/dao/xml/osm/OsmXmlRoot.java
// @XmlRootElement(name = "osm")
// public class OsmXmlRoot {
// 
// 	@XmlAttribute
// 	public float version;
// 
// 	@XmlAttribute
// 	public String generator;
// 
// 	@XmlElement(name = "node")
// 	public List<OsmXmlNode> nodes = new ArrayList<>();;
// 
// 	@XmlElement(name = "way")
// 	public List<OsmXmlWay> ways = new ArrayList<>();;
// 
// 	@XmlElement(name = "relations")
// 	public List<OsmXmlRelation> relations = new ArrayList<>();
// 
// }


// Path: src/main/java/org/openstreetmap/osmaxil/dao/OsmXmlFile.java
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.annotation.PreDestroy;
import javax.xml.transform.stream.StreamResult;
import org.apache.log4j.Logger;
import org.openstreetmap.osmaxil.Application;
import org.openstreetmap.osmaxil.dao.xml.osm.OsmXmlRoot;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.oxm.Marshaller;
import org.springframework.stereotype.Repository;

package org.openstreetmap.osmaxil.dao;




@Repository
public class OsmXmlFile {

	@Autowired
	@Qualifier(value = "osmMarshaller")
	private Marshaller marshaller;

	private int counterForWriteSuccess;

	private int counterForWriteFailures;

	static private final Logger LOGGER = Logger.getLogger(Application.class);

	static private final Logger LOGGER_FOR_STATS = Logger.getLogger("LoggerForStats");

	static private final String GEN_DIR = "gen";

	@PreDestroy
	public void close() {
		LOGGER_FOR_STATS.info("=== Closing OSM XML service ===");
		LOGGER_FOR_STATS.info("Total of writing successes: " + this.counterForWriteSuccess);
		LOGGER_FOR_STATS.info("Total of writing failures: " + this.counterForWriteFailures);
	}

	public boolean writeToFile(String name, OsmXmlRoot root) {
		boolean result = false;
		String fileName = null;
		FileOutputStream os = null;
		try {
			root.version = 0.6f;

			root.generator = Application.NAME;
