Class StudioViewUtils

java.lang.Object
com.axelor.studio.utils.StudioViewUtils

public final class StudioViewUtils extends Object
  • Method Details

    • toEntityName

      public static String toEntityName(StudioResource resource)
    • ensureTitle

      public static String ensureTitle(String title, String name)
    • toView

      public static AbstractView toView(StudioResource resource)
    • findUid

      public static String findUid(StudioResource resource)
      Studio's stable identity as recorded in the resource content, or null when it has none yet.

      Read-only on purpose. Writing the uid during a deploy would save the resource and bump its row version, and a designer holding the document open still has the version it loaded — its next save then fails the optimistic-lock check with "Record was updated or deleted by another transaction". Deploying must never invalidate an open designer session, so the uid is written only by the save path (see StudioResourceService.saveView), where the row is being saved anyway and the client gets the new version back in the response.

      Parameters:
      resource - the resource
      Returns:
      the stable uid, or null
    • applyUid

      public static String applyUid(StudioResource resource)
      Mints Studio's stable identity into the resource content if it carries none, and returns it. The content is patched in memory only — the caller is responsible for saving, so this must be called from a path that already persists the resource.

      Patches the content as a JsonNode instead of round-tripping it through StudioContent: the designer stores its node graph as verbatim JSON, and a typed round-trip would quietly drop or reorder anything the schema beans don't model.

      Parameters:
      resource - the resource
      Returns:
      the stable uid, or null when there is no content to carry one
    • toDeployableView

      public static AbstractView toDeployableView(AbstractView view)
      Resolves the view to deploy or export for a Studio-authored view: an <extend> fragment against the module-authored original when one exists, so the Studio customization composes with module extensions the same way any other extension does — instead of a full snapshot that masks the computed result and gets masked back after any module recompute. A brand-new Studio view (no module-authored original) passes through unchanged.

      The original is the module-composed view (base plus every module-authored extension), not the bare base: the designer is seeded from the composed view, so anything the module extensions contribute is already in the Studio content and must not be re-derived as a Studio change — see StudioMetaUtils.findModuleComposedView(java.lang.String, java.lang.String, java.lang.String).

      The content's own xmlId is the base view the designer was seeded from, so it pins the diff to that exact view; name/type/model alone can match several. It is only ever read here — never written to the deployed row, which carries Studio's own findUid(com.axelor.studio.db.StudioResource) identity instead.

    • toJsonAttrs

      public static Map<String,Object> toJsonAttrs(StudioJsonField field)
    • toModel

      public static StudioJsonModel toModel(StudioResource resource)
    • toField

      public static StudioJsonField toField(StudioResource resource)
    • toContent

      public static <T extends StudioContent<?>> T toContent(StudioResource resource, Class<T> type)
    • toMenu

      public static StudioJsonMenu toMenu(StudioResource resource)
    • toAction

      public static StudioJsonAction<?,?> toAction(StudioResource resource)
    • toSelect

      public static StudioJsonSelect toSelect(StudioResource resource)
    • toQuery

      public static StudioJsonQuery toQuery(StudioResource resource)
    • toWorkflow

      public static StudioJsonWorkflow toWorkflow(StudioResource resource)