Class DynamicViewExtensionGenerator

java.lang.Object
io.jmix.dynmodelflowui.impl.DynamicViewExtensionGenerator

@Component("dynmod_DynamicViewExtensionGenerator") public class DynamicViewExtensionGenerator extends Object
Generates a <view extends="…"> extension XML that adds a static entity's dynamic attributes to an existing view, targeting the dataGrid (columns) or formLayout (components) bound to the entity's data container. Supports a fresh build and a merge that adds missing attributes and removes ones no longer in the model.
  • Field Details

  • Constructor Details

    • DynamicViewExtensionGenerator

      public DynamicViewExtensionGenerator()
  • Method Details

    • generate

      public DynamicViewExtensionGenerator.ExtensionResult generate(@Nullable String viewId, DynamicEntityModel entity)
    • merge

      public DynamicViewExtensionGenerator.ExtensionResult merge(String source, @Nullable String viewId, DynamicEntityModel entity)
    • resolveView

      protected DynamicViewExtensionGenerator.ResolvedView resolveView(@Nullable String viewId, DynamicEntityModel entity)
    • unwrap

      protected Class<? extends View<?>> unwrap(Class<? extends View<?>> controllerClass)
      Unwraps a dynmod-generated controller (whose descriptor is itself a view-template extension) back to the original static controller, so we extend the real view rather than a previously deployed extension. Mirrors DynamicViewDeployer.unwrapDynamicStaticViewController.
    • isTemplateDescriptor

      protected boolean isTemplateDescriptor(Class<?> controllerClass)
    • resolveEntityFqn

      protected @Nullable String resolveEntityFqn(DynamicEntityModel entity)
    • displayableAttributes

      protected List<DynamicAttributeModel> displayableAttributes(DynamicEntityModel entity)
    • resolveTarget

      public @Nullable DynamicViewExtensionGenerator.TargetRef resolveTarget(org.dom4j.Element baseRoot, @Nullable String entityFqn)
    • buildFresh

    • buildMerge

    • addAllAbsent

      protected void addAllAbsent(List<String> target, List<String> source)
    • childByName

      protected @Nullable org.dom4j.Element childByName(org.dom4j.Element parent, String name)
    • findByNameAndId

      protected @Nullable org.dom4j.Element findByNameAndId(org.dom4j.Element element, String name, @Nullable String id)
    • ensureChild

      protected org.dom4j.Element ensureChild(org.dom4j.Element parent, String name)
    • collectProperties

      protected Set<String> collectProperties(@Nullable org.dom4j.Element targetElem, String kind)
    • referenceAttributes

      protected List<DynamicAttributeModel> referenceAttributes(List<DynamicAttributeModel> attrs)
    • reconcileReferenceFetchPlan

      protected DynamicViewExtensionGenerator.FetchPlanDelta reconcileReferenceFetchPlan(org.dom4j.Element root, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> references)
      Ensures the container fetch plan in root contains a <property> for each reference attribute and drops the ones no longer in the model, preserving properties already present in the base view's container fetch plan. No-op when there is nothing to add and no existing fetch plan to clean.
    • pruneEmptyUpwards

      protected void pruneEmptyUpwards(@Nullable org.dom4j.Element element)
      Detaches an element and its ancestors while they have no child elements, stopping at the view.
    • addFetchPlanProperty

      protected void addFetchPlanProperty(org.dom4j.Element fetchPlan, String name)
    • fetchPlanPropertyNames

      protected Set<String> fetchPlanPropertyNames(@Nullable org.dom4j.Element fetchPlan)
    • findContainerFetchPlan

      protected @Nullable org.dom4j.Element findContainerFetchPlan(org.dom4j.Element root, org.dom4j.Element baseContainer)
    • ensureContainerFetchPlan

      protected org.dom4j.Element ensureContainerFetchPlan(org.dom4j.Element root, org.dom4j.Element baseContainer)
    • containerPath

      protected List<org.dom4j.Element> containerPath(org.dom4j.Element container)
      Path of container elements from the <data> root (exclusive) down to container.
    • ensureDataElement

      protected org.dom4j.Element ensureDataElement(org.dom4j.Element root)
      Ensures <data> is the first child of the view so it precedes <layout>.
    • findChildWithId

      protected @Nullable org.dom4j.Element findChildWithId(org.dom4j.Element parent, String name, @Nullable String id)
    • ensureChildWithId

      protected org.dom4j.Element ensureChildWithId(org.dom4j.Element parent, String name, @Nullable String id)
    • findById

      protected @Nullable org.dom4j.Element findById(org.dom4j.Element element, @Nullable String id)
    • collectContainerIds

      protected void collectContainerIds(org.dom4j.Element element, String entityFqn, Set<String> ids)
    • findBound

      protected @Nullable org.dom4j.Element findBound(org.dom4j.Element element, String name, Set<String> containerIds)
    • addChild

      protected org.dom4j.Element addChild(org.dom4j.Element parent, String name)
    • writeXml

      protected String writeXml(org.dom4j.Document document)