/* * Licensed Materials - Property of Perforce Software, Inc. * © Copyright Perforce Software, Inc. 2014, 2021 * © Copyright IBM Corp. 2009, 2014 * © Copyright ILOG 1996, 2009 * All Rights Reserved. * * Note to U.S. Government Users Restricted Rights: * The Software and Documentation were developed at private expense and * are "Commercial Items" as that term is defined at 48 CFR 2.101, * consisting of "Commercial Computer Software" and * "Commercial Computer Software Documentation", as such terms are * used in 48 CFR 12.212 or 48 CFR 227.7202-1 through 227.7202-4, * as applicable. */ package monitoring.web.utils; import ilog.cpl.model.IlpObject; import monitoring.shared.MonitoringConstants; import shared.ResourceUtils; /** * This class provides client-side styling for managed services. * It can be used either in a table or tree JSF component. * <p> * The mapped properties are: * <ol> * <li>Icon URI * <li>Profile color * <li>profile name * </ol> */ public class ServiceStylingUtils { // Icon URIs private static final String BASE_PATH = "/resources/images/managed-objects"; private static final String UNKNOWN_ICON = BASE_PATH + "/unknown.gif"; private static final String CUSTOMER1_ICON = BASE_PATH + "/customer1.gif"; private static final String CUSTOMER2_ICON = BASE_PATH + "/customer2.gif"; private static final String CUSTOMER3_ICON = BASE_PATH + "/customer3.gif"; private static final String CUSTOMER4_ICON = BASE_PATH + "/customer4.gif"; private static final String PROVIDER_ICON = BASE_PATH + "/ilog.gif"; private static final String SLA_ICON = BASE_PATH + "/sla.gif"; private static final String SERVICE_ICON = BASE_PATH + "/service.gif"; private static final String PROFILE_STYLE = "font-size:10px; font-weight: bold; color: "; private static final String PLATINUM_COLOR = PROFILE_STYLE + "#0000FF;"; private static final String GOLD_COLOR = PROFILE_STYLE + "#FF9900;"; private static final String SILVER_COLOR = PROFILE_STYLE + "#666666;"; private static final String BRONZE_COLOR = PROFILE_STYLE + "#996600;"; private static final Integer PLATINUM_VALUE = Integer.valueOf(1); private static final Integer GOLD_VALUE = Integer.valueOf(2); private static final Integer SILVER_VALUE = Integer.valueOf(3); private static final Integer BRONZE_VALUE = Integer.valueOf(4); /** * Returns the URI to the image to be used as representation of * a given alarm object. */ public static String getIconURI(IlpObject node) { String cName = node.getIlpClass().getName(); if (cName.equals(MonitoringConstants.CUSTOMER_CLASS_NAME)) { Object id = node.getIdentifier(); if (id.equals(MonitoringConstants.CUSTOMER_CLASS_NAME + "1")) { return CUSTOMER1_ICON; } else if (id.equals(MonitoringConstants.CUSTOMER_CLASS_NAME + "2")) { return CUSTOMER2_ICON; } else if (id.equals(MonitoringConstants.CUSTOMER_CLASS_NAME + "3")) { return CUSTOMER3_ICON; } else if (id.equals(MonitoringConstants.CUSTOMER_CLASS_NAME + "4")) { return CUSTOMER4_ICON; } else if (id.equals(MonitoringConstants.PROVIDER_CLASS_NAME)) { return PROVIDER_ICON; } } else if (cName.equals(MonitoringConstants.SLA_CLASS_NAME)) { return SLA_ICON; } else if (cName.equals(MonitoringConstants.SERVICE_CLASS_NAME)) { return SERVICE_ICON; } return UNKNOWN_ICON; } /** * Returns the "color" of the profile that is set of the provided object. */ public static String getProfileColor(IlpObject cell) { if ("Service".equals(cell.getIlpClass().getName())) { Object attributeValue = cell.getAttributeValue("SLAProfile"); if(attributeValue instanceof Integer) { if (PLATINUM_VALUE.equals(attributeValue)) { return PLATINUM_COLOR; } else if (GOLD_VALUE.equals(attributeValue)) { return GOLD_COLOR; } else if (SILVER_VALUE.equals(attributeValue)) { return SILVER_COLOR; } else if (BRONZE_VALUE.equals(attributeValue)) { return BRONZE_COLOR; } } } return PROFILE_STYLE + "000000"; } /** * Returns the "name" of the profile that is set of the provided object. */ public static String getProfileName(IlpObject cell) { if ("Service".equals(cell.getIlpClass().getName())) { Object attributeValue = cell.getAttributeValue("SLAProfile"); if(attributeValue instanceof Integer) { if (PLATINUM_VALUE.equals(attributeValue)) { return ResourceUtils.getString("labelProfilePlatinum"); } else if (GOLD_VALUE.equals(attributeValue)) { return ResourceUtils.getString("labelProfileGold"); } else if (SILVER_VALUE.equals(attributeValue)) { return ResourceUtils.getString("labelProfileSilver"); } else if (BRONZE_VALUE.equals(attributeValue)) { return ResourceUtils.getString("labelProfileBronze"); } } } return ResourceUtils.getString("labelProfileUnknown"); } }