Class DraftInfoSupport

java.lang.Object
io.jmix.uirecoveryflowui.view.draft.DraftInfoSupport

@NullMarked @Component("uirec_DraftInfoSupport") public class DraftInfoSupport extends Object
Turns ViewDraft rows into the DraftInfo entries the drafts list view renders.

A draft stores only the view identifier and the identifier of the edited instance, so everything a card shows - the view title, the record name and the address to link to - is resolved here. Every lookup degrades instead of failing: a view that is no longer registered yields no address, and a record that cannot be loaded yields no name.

  • Field Details

    • MESSAGE_GROUP

      protected static final String MESSAGE_GROUP
    • ENTITY_ID_ROUTE_PARAM

      protected static final String ENTITY_ID_ROUTE_PARAM
      See Also:
    • viewRegistry

      @Autowired protected ViewRegistry viewRegistry
    • viewSupport

      @Autowired protected ViewSupport viewSupport
    • idSerialization

      @Autowired protected IdSerialization idSerialization
    • dataManager

      @Autowired protected DataManager dataManager
    • metadataTools

      @Autowired protected MetadataTools metadataTools
    • routeSupport

      @Autowired protected RouteSupport routeSupport
    • messages

      @Autowired protected Messages messages
    • currentAuthentication

      @Autowired protected CurrentAuthentication currentAuthentication
  • Constructor Details

    • DraftInfoSupport

      public DraftInfoSupport()
  • Method Details

    • createInfos

      public List<DraftInfo> createInfos(Collection<ViewDraft> drafts)
      Builds an entry for each of the given drafts, keeping their order.
      Parameters:
      drafts - drafts to describe
      Returns:
      one entry per draft
    • createInfo

      public DraftInfo createInfo(ViewDraft draft)
      Builds the entry for a single draft.
      Parameters:
      draft - draft to describe
      Returns:
      the entry
    • getViewTitle

      protected String getViewTitle(String viewId, @Nullable ViewInfo viewInfo)
      Parameters:
      viewId - identifier of the view the draft belongs to
      viewInfo - registration of that view, or null if it is not registered any more
      Returns:
      the localized view title, falling back to the identifier when the view is gone or declares no title
    • getRecordName

      protected @Nullable String getRecordName(@Nullable String entityId)
      Loads the drafted record to name it. A draft not tied to an instance, and the marker of an instance that was never persisted, have no record to load.
      Parameters:
      entityId - identifier of the drafted instance, or null
      Returns:
      the instance name, or null if there is nothing to name or it cannot be loaded
    • getUrl

      protected @Nullable String getUrl(ViewInfo viewInfo, @Nullable String entityId)
      Parameters:
      viewInfo - registration of the view the draft belongs to
      entityId - identifier of the drafted instance, or null
      Returns:
      the address of that view, or null if it cannot be built
    • getRouteParameters

      protected com.vaadin.flow.router.RouteParameters getRouteParameters(@Nullable String entityId)
      Route parameters that address the drafted instance, built the same way navigating to a detail view builds them, so that the link opens exactly the view the draft was captured from.
      Parameters:
      entityId - identifier of the drafted instance, or null
      Returns:
      the route parameters, empty for a draft not tied to an instance
    • parseEntityId

      protected @Nullable Id<?> parseEntityId(String entityId)
      Parameters:
      entityId - identifier of the drafted instance
      Returns:
      the parsed identifier, or null if it cannot be parsed
    • formatSavedDate

      protected String formatSavedDate(@Nullable OffsetDateTime createdDate)
      Parameters:
      createdDate - the moment the draft was saved
      Returns:
      that moment in the current user's time zone and locale
    • getRouteConfiguration

      protected com.vaadin.flow.router.RouteConfiguration getRouteConfiguration()