package depart.dorsal.taches;

import static ca.ntro.app.tasks.backend.BackendTasks.*;

import ca.ntro.app.tasks.backend.BackendTasks;
import depart.commun.messages.MsgB;
import depart.commun.messages.MsgD;
import depart.commun.modeles.ModeleB;

public class TachesH {
	
	public static void creerTaches(BackendTasks tasks) {

		tasks.taskGroup("TachesH")

		     .waitsFor(model(ModeleB.class))
		
		     .contains(subTasks -> {
		    	  
		    	 tacheH1(subTasks);
		    	 
		    	 tacheH2(subTasks);

		     });
	}

	private static void tacheH1(BackendTasks subTasks) {

		subTasks.task("tacheH1")

		     .waitsFor(model(ModeleB.class))

		     .waitsFor(message(MsgB.class))

		     .executes(inputs -> {

		    	 var objA = inputs.get(message(MsgB.class));
		    	 var objB = inputs.get(model(ModeleB.class));

		    	 objA.methodeA(objB);
		     });
	}

	private static void tacheH2(BackendTasks subTasks) {

		subTasks.task("tacheH2")

		     .waitsFor(model(ModeleB.class))

		     .waitsFor(message(MsgD.class))

		     .executes(inputs -> {

		    	 var objA = inputs.get(message(MsgD.class));
		    	 var objB = inputs.get(model(ModeleB.class));

		    	 objA.methodeA(objB);
		     });
	}

}
