package org.ovirt.engine.ui.webadmin.widget.table.column;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.ovirt.engine.core.common.businessentities.ExternalStatus;
import org.ovirt.engine.core.common.businessentities.VDS;
import org.ovirt.engine.ui.webadmin.ApplicationConstants;
import org.ovirt.engine.ui.webadmin.gin.AssetProvider;
import com.google.gwt.resources.client.ImageResource;
import com.google.gwt.safehtml.shared.SafeHtml;

public class HostAdditionalStatusColumn extends EntityAdditionalStatusColumn<VDS> {

    private final static ApplicationConstants constants = AssetProvider.getConstants();


    @Override
    public SafeHtml getEntityValue(VDS object) {
        List<SafeHtml> imagesHtml = new ArrayList(getSafeHtmlStringMap(object).keySet());
        if (! imagesHtml.isEmpty()) {
            return MultiImageColumnHelper.getValue(imagesHtml);
        }
        return null;
    }

    @Override
    public SafeHtml getEntityTooltip(VDS object) {
        Map<SafeHtml, String> imagesToText = getSafeHtmlStringMap(object);
        if (!imagesToText.isEmpty()) {
            return MultiImageColumnHelper.getTooltip(imagesToText);
        }
        return null;
    }

    private Map<SafeHtml, String> getSafeHtmlStringMap(VDS object) {
        VDS host = getEntityObject(object);
        Map<SafeHtml, String> imagesToText = new LinkedHashMap<>();
        ExternalStatus externalStatus = host.getExternalStatus();

        if (host.isUpdateAvailable()) {
            imagesToText.put(getImageSafeHtml(resources.updateAvailableImage()), constants.updateAvailable());
        }
        if (externalStatus != null && host.getExternalStatus() != ExternalStatus.Ok) {
            ImageResource statusImage = getStatusImage(externalStatus);
            imagesToText.put(getImageSafeHtml(statusImage),
                    constants.ExternalStatus() + externalStatus.name());
        }
        return imagesToText;
    }

    @Override
    protected VDS getEntityObject(VDS object) {
        return object;
    }
}

@@ -1822,16 +1822,59 @@
 tatus);%0A
+            if (statusImage != null) %7B%0A    
         
@@ -1945,16 +1945,20 @@
         
+   
+ 
 constant
@@ -1998,24 +1998,38 @@
 us.name());%0A
+            %7D%0A
         %7D%0A  

resolve Coverity issue 1306186