package de.atomfrede.mate.service.admin;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import de.atomfrede.mate.domain.dao.bottle.BottleDao;
import de.atomfrede.mate.domain.dao.consumption.ConsumptionDao;
import de.atomfrede.mate.domain.dao.user.UserDao;
import de.atomfrede.mate.domain.entities.bottle.Bottle;
import de.atomfrede.mate.domain.entities.consumption.Consumption;
import de.atomfrede.mate.domain.entities.user.User;


@Service(value = "adminService")
@Transactional(rollbackFor = Exception.class)
public class AdminServiceImpl implements AdminService {

	@Autowired
	private UserDao userdao;
	
	@Autowired
	private ConsumptionDao consumptions;
	
	@Autowired
	private BottleDao bottles;
	
	@Override
	public void clearAllData() {
		for(User u:userdao.findAll()) {
			u.getAccount().reset();
			u.getConsumptions().clear();
		}
		
		for(Consumption con:consumptions.findAll()) {
			consumptions.remove(con);
		}
		
		for(Bottle b:bottles.findAll()) {
			bottles.remove(b);
		}
	}

	@Override
	public void clearData(User user) {
		// TODO Auto-generated method stub

	}

}

@@ -828,32 +828,48 @@
 s;%0A%09%0A%09@Override%0A
+%09@Transactional%0A
 %09public void cle
@@ -1143,16 +1143,32 @@
 verride%0A
+%09@Transactional%0A
 %09public 
@@ -1201,43 +1201,118 @@
 %7B%0A%09%09
-// TODO Auto-generated method stub%0A
+user.getAccount().reset();%0A%09%09%0A%09%09for(Consumption con:user.getConsumptions()) %7B%0A%09%09%09consumptions.remove(con);%0A%09%09%7D
 %0A%09%7D%0A

Update #12