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 BaseViewXmlProviderprotected DynamicAttributeComponentXmlFactoryprotected static final Stringprotected static final Stringprotected Metadataprotected DynamicModelPackageSupportprotected static final StringNested fetch plan used when pulling a dynamic reference into the container fetch plan.protected static final Stringprotected static final String -
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) protected StringbasePackage(@Nullable DynamicModelDefinitionModel model) buildFresh(String extendsPath, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> attrs, String basePackage) buildMerge(String source, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> attrs, String basePackage) 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 DynamicModelDefinitionModel model, @Nullable String viewId, DynamicEntityModel entity) merge(@Nullable DynamicModelDefinitionModel model, 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) protected @Nullable StringresolveReferencedEntityClass(DynamicAttributeModel attribute, String basePackage) Resolves the class name a reference attribute points to, ornullfor a non-reference attribute.@Nullable DynamicViewExtensionGenerator.TargetRefresolveTarget(org.dom4j.Element baseRoot, @Nullable String entityFqn) resolveView(@Nullable String viewId, DynamicEntityModel entity) 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:
-
baseViewXmlProvider
-
metadata
-
componentXmlFactory
-
packageSupport
-
-
Constructor Details
-
DynamicViewExtensionGenerator
public DynamicViewExtensionGenerator()
-
-
Method Details
-
generate
public DynamicViewExtensionGenerator.ExtensionResult generate(@Nullable DynamicModelDefinitionModel model, @Nullable String viewId, DynamicEntityModel entity) -
merge
public DynamicViewExtensionGenerator.ExtensionResult merge(@Nullable DynamicModelDefinitionModel model, String source, @Nullable String viewId, DynamicEntityModel entity) -
basePackage
-
resolveReferencedEntityClass
protected @Nullable String resolveReferencedEntityClass(DynamicAttributeModel attribute, String basePackage) Resolves the class name a reference attribute points to, ornullfor a non-reference attribute. A dynamic entity that is not applied yet has no metadata, so the name it gets on apply is used. -
resolveView
protected DynamicViewExtensionGenerator.ResolvedView resolveView(@Nullable String viewId, DynamicEntityModel entity) -
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, String basePackage) -
buildMerge
public DynamicViewExtensionGenerator.ExtensionResult buildMerge(String source, DynamicViewExtensionGenerator.TargetRef target, List<DynamicAttributeModel> attrs, String basePackage) -
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
-