/**
 * 
 */
package io.github.pbremer.icecreammanager.batch;

import java.util.ArrayList;
import java.util.List;

import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;

import io.github.pbremer.icecreammanager.entity.Route;
import io.github.pbremer.icecreammanager.service.RouteService;

/**
 * @author Patrick Bremer
 */
public class RouteItemWriter implements ItemWriter<Route> {

    @Autowired
    private RouteService routeService;

    /*
     * (non-Javadoc)
     * @see org.springframework.batch.item.ItemWriter#write(java.util.List)
     */
    @Override
    public void write(List<? extends Route> items) throws Exception {
	List<Route> inactiveRoutes = new ArrayList<Route>();
	List<Route> activeRoutes = new ArrayList<Route>();
	for (Route route : items) {
	    if (route.getActive()) {
		activeRoutes.add(route);
	    } else {
		inactiveRoutes.add(route);
	    }
	}
	routeService.batchSave(activeRoutes);
    }

}

@@ -936,31 +936,150 @@
 %09%7D%0A%09
-routeService.batchSave(
+if (!activeRoutes.isEmpty())%0A%09    routeService.batchSave(activeRoutes);%0A%0A%09if (!inactiveRoutes.isEmpty())%0A%09    routeService.inactivateRoutes(in
 acti

fix for delete route test