package org.ovirt.engine.core.vdsbroker;

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

import org.ovirt.engine.core.common.businessentities.VDS;

public class MultipleServicesMonitoringStrategy implements MonitoringStrategy {

    List<MonitoringStrategy> strategies = new ArrayList<MonitoringStrategy>();

    public MultipleServicesMonitoringStrategy() {
    }

    public void addMonitoringStrategy( MonitoringStrategy monitoringStrategy ) {
        strategies.add(monitoringStrategy);
    }

    @Override
    public void processHardwareCapabilities(VDS vds) {
        for ( MonitoringStrategy monitoringStrategy : strategies ) {
            monitoringStrategy.processHardwareCapabilities(vds);
        }
    }

    @Override
    public void processSoftwareCapabilities(VDS vds) {
        for ( MonitoringStrategy monitoringStrategy : strategies ) {
            monitoringStrategy.processSoftwareCapabilities(vds);
        }
    }

    @Override
    public boolean canMoveToMaintenance(VDS vds) {
        // In this case, if all the services can move the VDS to maintenance then we return true
        for ( MonitoringStrategy monitoringStrategy : strategies ) {
            if (!monitoringStrategy.canMoveToMaintenance(vds)) {
                return false;
            }
        }
        return true;
    }

    @Override
    public boolean isMonitoringNeeded(VDS vds) {
        // In this case, if one of the services needs monitoring then we return true
        for ( MonitoringStrategy monitoringStrategy : strategies ) {
            if (monitoringStrategy.isMonitoringNeeded(vds)) {
                return true;
            }
        }
        return false;
    }

}

@@ -1675,10 +1675,449 @@
 %0A    %7D%0A%0A
+    @Override%0A    public boolean processHardwareCapabilitiesNeeded(VDS oldVds, VDS newVds) %7B%0A        // In this case, if one of the services needs hardware capabilities processing then we return true%0A        for ( MonitoringStrategy monitoringStrategy : strategies ) %7B%0A            if (monitoringStrategy.processHardwareCapabilitiesNeeded(oldVds, newVds)) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%0A
 %7D%0A

add unimplemented method to MultipleServiceMonitoringStrategy