// Path: src/de/endrullis/utils/VelocityUtils.java
// public class VelocityUtils {
// 	private static boolean initialized = false;
// 
// 	public static void init() throws Exception {
// 		if (initialized) return;
// 
// 		// initialize Velocity
// 		InputStream inputStream = StreamUtils.getInputStream("velocity.properties");
// 		Properties properties = new Properties();
// 		properties.load(inputStream);
// 		Velocity.init(properties);
// 
// 		initialized = true;
// 	}
// 
// 
// 	public static Template getTemplate(String name) throws Exception {
// 		init();
// 
// 		InputStream resourceAsStream = VelocityUtils.class.getResourceAsStream("/" + name);
// 		if (resourceAsStream == null) throw new ResourceNotFoundException("Resource " + name + " could not be found");
// 
// 		// get the template
// 		return Velocity.getTemplate(name);
// 	}
// }


import de.endrullis.utils.VelocityUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import java.io.*;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;

			statsTotal.duration++;
			if (record.pulse > 0) {
				statsTotal.pulseCount++;
				statsTotal.pulseSum += record.pulse;
			}
			statsTotal.powerSum += record.power;
			statsTotal.pedalRpmSum += record.pedalRpm;
		}

		needToBeSaved = true;
	}

	public void save(String dir) throws IOException {
		new File(dir).mkdirs();
		String filename = getFileName(dir + "/", startTime);
		String filenameHRM = filename + ".hrm";
		file = new File(getFileName(dir + "/", startTime));
		DataOutputStream out = new DataOutputStream(new FileOutputStream(file));

		toStream(out);
		out.close();

		toHRM(filenameHRM);
		needToBeSaved = false;
	}

	private void toHRM(String filename) {
		VelocityContext context = new VelocityContext();
		try {
// Path: src/de/endrullis/utils/VelocityUtils.java
// public class VelocityUtils {
// 	private static boolean initialized = false;
// 
// 	public static void init() throws Exception {
// 		if (initialized) return;
// 
// 		// initialize Velocity
// 		InputStream inputStream = StreamUtils.getInputStream("velocity.properties");
// 		Properties properties = new Properties();
// 		properties.load(inputStream);
// 		Velocity.init(properties);
// 
// 		initialized = true;
// 	}
// 
// 
// 	public static Template getTemplate(String name) throws Exception {
// 		init();
// 
// 		InputStream resourceAsStream = VelocityUtils.class.getResourceAsStream("/" + name);
// 		if (resourceAsStream == null) throw new ResourceNotFoundException("Resource " + name + " could not be found");
// 
// 		// get the template
// 		return Velocity.getTemplate(name);
// 	}
// }


// Path: src/org/jergometer/model/BikeSession.java
import de.endrullis.utils.VelocityUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import java.io.*;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;


			statsTotal.duration++;
			if (record.pulse > 0) {
				statsTotal.pulseCount++;
				statsTotal.pulseSum += record.pulse;
			}
			statsTotal.powerSum += record.power;
			statsTotal.pedalRpmSum += record.pedalRpm;
		}

		needToBeSaved = true;
	}

	public void save(String dir) throws IOException {
		new File(dir).mkdirs();
		String filename = getFileName(dir + "/", startTime);
		String filenameHRM = filename + ".hrm";
		file = new File(getFileName(dir + "/", startTime));
		DataOutputStream out = new DataOutputStream(new FileOutputStream(file));

		toStream(out);
		out.close();

		toHRM(filenameHRM);
		needToBeSaved = false;
	}

	private void toHRM(String filename) {
		VelocityContext context = new VelocityContext();
		try {
			Template template = VelocityUtils.getTemplate("org/jergometer/model/templates/hrm.template");