/** * */ package com.onaro.sanscreen.client.view.changes; import java.text.DateFormat; import java.util.Date; import org.apache.commons.lang3.StringUtils; import com.onaro.sanscreen.server.interfaces.data.AbstractDataObjectDescription; import com.onaro.sanscreen.server.interfaces.data.IDataObjectDescription; import com.onaro.sanscreen.server.interfaces.data.TimeContext; import com.onaro.sanscreen.types.ChangeType; /** * Creates an {@link IDataObjectDescription} instance for a {@link ChangesSelectedObject}. */ /*package*/ final class ChangesDescription extends AbstractDataObjectDescription { private static final DateFormat dateFormat = DateFormat.getDateTimeInstance (DateFormat.SHORT, DateFormat.SHORT); private final ChangeType changeType; private final Date changeTime; /** * @param changeType {@link ChangeType} * @param changeTime {@link TimeContext} */ public ChangesDescription (ChangeType changeType, Date changeTime) { this.changeType = changeType; this.changeTime = changeTime; } @Override public String getName() { // Use change type for name. return changeType.getDescription(); } @Override public String getLongDescription() { String timestamp = changeTime == null? StringUtils.EMPTY : dateFormat.format (changeTime); // TODO: Replace changeType.getDescription() with algorithm that uses SummaryFactory class. // See defect 23550. return com.onaro.sanscreen.client.Messages.INSTANCE.getChangeSelectionHtml ( timestamp, changeType.getDescription()); } }