List of usage examples for org.hibernate.pretty MessageHelper infoString
public static String infoString(String entityName, Serializable id)
From source file:com.mg.framework.service.DatabaseAuditServiceImpl.java
License:Open Source License
private String entityPropertyToString(Object state, ClassMetadata metadata) { if (state != null) { Serializable id = metadata.getIdentifier(state, EntityMode.POJO); return MessageHelper.infoString(metadata.getEntityName(), id); } else/*from w ww . j a v a 2 s . com*/ return null; }
From source file:org.openvpms.web.component.im.delete.AbstractIMObjectDeletionListener.java
License:Open Source License
/** * Notifies that an object has failed to be deleted. * <p>//from ww w .j a va 2s.c om * This implementation displays an error dialog. * * @param object the object that failed to be deleted * @param cause the reason for the failure */ @SuppressWarnings("ThrowableResultOfMethodCallIgnored ") public void failed(T object, Throwable cause) { String displayName = DescriptorHelper.getDisplayName(object); Throwable rootCause = ExceptionHelper.getRootCause(cause); String title = Messages.get("imobject.delete.failed.title"); if (ExceptionHelper.isModifiedExternally(rootCause)) { // Delete failed as the object (or a related object) has already been deleted // Don't propagate the exception String message; if (rootCause instanceof ObjectNotFoundException) { ObjectNotFoundException notFoundException = (ObjectNotFoundException) rootCause; Serializable identifier = notFoundException.getIdentifier(); if (identifier != null && Long.toString(object.getId()).equals(identifier.toString())) { // really need to look at the entity name, to ensure they are of the correct type. TODO message = Messages.format("imobject.notfound", displayName); } else { // TODO - really want an IMObjectReference to get the display name. message = Messages.format("imobject.notfound", MessageHelper.infoString(notFoundException.getEntityName(), identifier)); } } else { message = ErrorFormatter.format(cause, ErrorFormatter.Category.DELETE, displayName); } ErrorHelper.show(title, message); } else { String context = Messages.format("imobject.delete.failed", object.getObjectReference()); ErrorHelper.show(title, context, cause); } }
From source file:org.openvpms.web.component.util.ErrorHelper.java
License:Open Source License
/** * Shows an error related to an object.//from w ww . jav a 2 s. c o m * * @param title the title. May be {@code null} * @param displayName the display name to include in the message. May be {@code null} * @param object the object * @param error the error */ public static void show(String title, String displayName, IMObject object, Throwable error) { Throwable cause = ExceptionHelper.getRootCause(error); if (displayName == null) { displayName = DescriptorHelper.getDisplayName(object); } if (ExceptionHelper.isModifiedExternally(cause)) { // Don't propagate the exception String message; if (cause instanceof ObjectNotFoundException) { ObjectNotFoundException notFoundException = (ObjectNotFoundException) cause; Serializable identifier = notFoundException.getIdentifier(); if (identifier != null && Long.toString(object.getId()).equals(identifier.toString())) { // really need to look at the entity name, to ensure they are of the correct type. TODO message = Messages.format("imobject.notfound", displayName); } else { // TODO - really want an IMObjectReference to get the display name. message = Messages.format("imobject.notfound", MessageHelper.infoString(notFoundException.getEntityName(), identifier)); } } else { message = ErrorFormatter.format(cause, displayName); } ErrorHandler.getInstance().error(title, message, null, null); } else { String message = ErrorFormatter.format(error, displayName); ErrorHandler.getInstance().error(title, message, error, null); } }