package com.onaro.sanscreen.client.view.changes.format; import java.util.ResourceBundle; import org.apache.commons.lang3.StringUtils; import com.onaro.sanscreen.server.changes.Change; import com.onaro.sanscreen.server.changes.ChangeConstants; import com.onaro.util.IllegalInitException; public class SummaryVolumeFormatter extends BaseFormatter { public SummaryVolumeFormatter(String key, ResourceBundle bundle) throws IllegalInitException { super(key, bundle); } protected String getResourceKey(Change change) throws IllegalInitException { String normalKey = super.getResourceKey(change); String volumeName = getValue(ChangeConstants.VOLUME_LIST, change, true); return normalKey + (volumeName != null ? StringUtils.EMPTY : ".allVolumes"); //$NON-NLS-1$ } protected String getValue(String attributeName, Change change, boolean allowNull, ChangeFormatPattern pattern) throws IllegalInitException { /** * The number of volumes grouped together was previously recorded in an attribute called NEW_VALUE. * In some change type the attribute NEW_VALUE was already in use. Thus the attribute representing the * volume count was changed to be VOLUME_COUNT. The following code is for old recorded changes. * In the future should move this tretment to the upgarde. */ if (ChangeConstants.VOLUME_COUNT.equals(attributeName)) { String volumeCount = change.getValue(ChangeConstants.VOLUME_COUNT); if (volumeCount==null) return change.getValue(ChangeConstants.NEW_VALUE); return volumeCount; } return super.getValue(attributeName, change, allowNull, pattern); } }