package org.ovirt.engine.core.bll;

import java.util.Collections;

import org.ovirt.engine.core.bll.host.provider.HostProviderProxy;
import org.ovirt.engine.core.bll.provider.ProviderProxyFactory;
import org.ovirt.engine.core.common.businessentities.Erratum;
import org.ovirt.engine.core.common.businessentities.Provider;
import org.ovirt.engine.core.common.businessentities.VdsStatic;
import org.ovirt.engine.core.common.queries.IdQueryParameters;

public class GetErrataForHostQuery<P extends IdQueryParameters> extends QueriesCommandBase<P> {

    public GetErrataForHostQuery(P parameters) {
        super(parameters);
    }

    @Override
    protected void executeQueryCommand() {
        VdsStatic host = getDbFacade().getVdsStaticDao().get(getParameters().getId());
        if (host == null || host.getHostProviderId() == null) {
            getQueryReturnValue().setReturnValue(Collections.<Erratum> emptyList());
            return;
        }

        Provider<?> provider = getDbFacade().getProviderDao().get(host.getHostProviderId());
        if (provider != null) {
            HostProviderProxy proxy = ProviderProxyFactory.getInstance().create(provider);
            getQueryReturnValue().setReturnValue(proxy.getErrataForHost(host.getHostName()));
        } else {
            getQueryReturnValue().setReturnValue(Collections.<Erratum> emptyList());
        }
    }
}

@@ -60,16 +60,45 @@
 tions;%0A%0A
+import javax.inject.Inject;%0A%0A
 import o
@@ -475,104 +475,309 @@
 rs;%0A
-%0Apublic class GetErrataForHostQuery%3CP extends IdQueryParameters%3E extends QueriesCommandBase%3CP%3E %7B
+import org.ovirt.engine.core.dao.VdsStaticDao;%0Aimport org.ovirt.engine.core.dao.provider.ProviderDao;%0A%0Apublic class GetErrataForHostQuery%3CP extends IdQueryParameters%3E extends QueriesCommandBase%3CP%3E %7B%0A%0A    @Inject%0A    private VdsStaticDao hostStaticDao;%0A%0A    @Inject%0A    private ProviderDao providerDao;
 %0A%0A  
@@ -943,28 +943,12 @@
 t = 
-getDbFacade().getVds
+host
 Stat
@@ -952,18 +952,16 @@
 taticDao
-()
 .get(get
@@ -1198,26 +1198,9 @@
 r = 
-getDbFacade().getP
+p
 rovi
@@ -1205,18 +1205,16 @@
 viderDao
-()
 .get(hos

Use injection