void Management::deleteBuildFromSlave(int machineID, int buildID){
    Machine *machine = getMachineById(machineID);

    if(machine == 0)
        return;

    if(machineWithBuild(machineID, buildID)){
        machine->deleteBuildNotify(buildID);
    }
}
void Management::addBuildToSlave(int machineId, int BuildID, QString buildName){

    Machine *machine = getMachineById(machineId);

    if(machine == 0)
        return;

    Build *trueBuild = getBuildByID(BuildID);

    if(trueBuild == 0){
        //this point the build does not exist
        emit slaveGotBuild(machine, BuildID, buildName, false);
        //this point that machine has a build it is not suppose to have...go and delete it
        machine->deleteBuild(BuildID);

        //notify the slave that it should delete the build
        machine->deleteBuildNotify(BuildID);
    }
    else{
        Build *buildToAdd = new Build(BuildID, buildName, "", trueBuild->getBuildDirectory());

        bool existMachineWithBuild = machineWithBuild(machine->getMachineID(), buildToAdd->getBuildID());

        //if there already exist that build for the machine, don't add it twice
        if(existMachineWithBuild == false)
            machine->addBuild(buildToAdd);
        else
            return;

        emit slaveGotBuild(machine, BuildID, buildName, true);

        //check if the build name corrolate with the information on the
        //slave side
        if(buildName.compare(trueBuild->getBuildName())){
            machine->updateBuildName(buildToAdd->getBuildID(), trueBuild->getBuildName());
        }
    }

}
void Management::deleteBuild(int buildID){

    //go and delete build
    //from (1):logical view point
    removeBuildLogically(buildID);

    //from (2):xml
    xmlWriter aWriter;
    aWriter.removeBuild(buildID);

    //from(3): all connected clients
    for(int i = 0; i < machineCount; i++){
        Machine *machine = getMachineAt(i);

        if(machine == 0)
            continue;

        //only notify the machine if that machine has the build
        machine->deleteBuildNotify(buildID);
    }

    //from(4):gui
    emit buildDeleted();
}