Package io.jmix.dynmodelflowui.impl
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordprotected static final recordprotected static final recordstatic final record -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DynamicAttributeComponentXmlFactoryprotected static final Stringprotected static final Stringprotected Metadataprotected static final StringNested fetch plan used when pulling a dynamic reference into the container fetch plan.protected static final Stringprotected static final Stringprotected ViewRegistryprotected ViewXmlLoader -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAllAbsent(List<String> target, List<String> source) protected org.dom4j.Elementprotected voidaddFetchPlanProperty(org.dom4j.Element fetchPlan, String name) buildFresh(String extendsPath, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> attrs) buildMerge(String source, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> attrs) protected @Nullable org.dom4j.ElementchildByName(org.dom4j.Element parent, String name) protected voidcollectContainerIds(org.dom4j.Element element, String entityFqn, Set<String> ids) collectProperties(@Nullable org.dom4j.Element targetElem, String kind) protected List<org.dom4j.Element> containerPath(org.dom4j.Element container) Path of container elements from the<data>root (exclusive) down tocontainer.protected List<DynamicAttributeModel> protected org.dom4j.ElementensureChild(org.dom4j.Element parent, String name) protected org.dom4j.ElementensureChildWithId(org.dom4j.Element parent, String name, @Nullable String id) protected org.dom4j.ElementensureContainerFetchPlan(org.dom4j.Element root, org.dom4j.Element baseContainer) protected org.dom4j.ElementensureDataElement(org.dom4j.Element root) Ensures<data>is the first child of the view so it precedes<layout>.fetchPlanPropertyNames(@Nullable org.dom4j.Element fetchPlan) protected @Nullable org.dom4j.Elementprotected @Nullable org.dom4j.Elementprotected @Nullable org.dom4j.ElementfindByNameAndId(org.dom4j.Element element, String name, @Nullable String id) protected @Nullable org.dom4j.ElementfindChildWithId(org.dom4j.Element parent, String name, @Nullable String id) protected @Nullable org.dom4j.ElementfindContainerFetchPlan(org.dom4j.Element root, org.dom4j.Element baseContainer) generate(@Nullable String viewId, DynamicEntityModel entity) protected booleanisTemplateDescriptor(Class<?> controllerClass) merge(String source, @Nullable String viewId, DynamicEntityModel entity) protected voidpruneEmptyUpwards(@Nullable org.dom4j.Element element) Detaches an element and its ancestors while they have no child elements, stopping at the view.reconcileReferenceFetchPlan(org.dom4j.Element root, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> references) Ensures the container fetch plan inrootcontains 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.protected List<DynamicAttributeModel> protected @Nullable StringresolveEntityFqn(DynamicEntityModel entity) @Nullable DynamicViewExtensionGenerator.TargetRefresolveTarget(org.dom4j.Element baseRoot, @Nullable String entityFqn) resolveView(@Nullable String viewId, DynamicEntityModel entity) 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.protected StringwriteXml(org.dom4j.Document document)
-
Field Details
-
VIEW_NAMESPACE_URI
- See Also:
-
VIEW_EXT_NAMESPACE_URI
- See Also:
-
DATA_GRID
- See Also:
-
FORM_LAYOUT
- See Also:
-
REFERENCE_FETCH_PLAN
Nested fetch plan used when pulling a dynamic reference into the container fetch plan.- See Also:
-
viewRegistry
-
viewXmlLoader
-
metadata
-
componentXmlFactory
-
-
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
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. MirrorsDynamicViewDeployer.unwrapDynamicStaticViewController. -
isTemplateDescriptor
-
resolveEntityFqn
-
displayableAttributes
-
resolveTarget
public @Nullable DynamicViewExtensionGenerator.TargetRef resolveTarget(org.dom4j.Element baseRoot, @Nullable String entityFqn) -
buildFresh
public DynamicViewExtensionGenerator.ExtensionResult buildFresh(String extendsPath, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> attrs) -
buildMerge
public DynamicViewExtensionGenerator.ExtensionResult buildMerge(String source, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> attrs) -
addAllAbsent
-
childByName
-
findByNameAndId
-
ensureChild
-
collectProperties
-
referenceAttributes
-
reconcileReferenceFetchPlan
protected DynamicViewExtensionGenerator.FetchPlanDelta reconcileReferenceFetchPlan(org.dom4j.Element root, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> references) Ensures the container fetch plan inrootcontains 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
-
fetchPlanPropertyNames
-
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
Path of container elements from the<data>root (exclusive) down tocontainer. -
ensureDataElement
protected org.dom4j.Element ensureDataElement(org.dom4j.Element root) Ensures<data>is the first child of the view so it precedes<layout>. -
findChildWithId
-
ensureChildWithId
-
findById
-
collectContainerIds
-
findBound
-
addChild
-
writeXml
-