Mandatory-enforce not overridable according to modelSchema.xsd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014 12:26 PM
When defining the mandatory attribute on a model property, one can use "enforced=true/false"
to control the enforcement of the "mandatory" constraint.
When overriding the mandatory attribute, you cant specify "enforced", as mandatory is "just" aboolean when overriding.
<xs:complexType name="property"> … <xs:element name="mandatory" maxOccurs="1" minOccurs="0" type="dd:mandatoryDef" /> … </xs:complexType> <xs:complexType name="propertyOverride"> … <xs:element name="mandatory" maxOccurs="1" minOccurs="0" type="xs:boolean" /> … </xs:complexType>
I think, this should be overridable…
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014 12:52 PM
e.g. the following example will enforce integrity check on foo:documentDate in the foo:child type,
<types> <type name="foo:parent"> … <properties> <property name="foo:documentDate"> <type>d:date</type> <mandatory enforced="true">false</mandatory> <multiple>false</multiple> </property> </properties> </type> <!– Rechnung –> <type name="foo:child"> … <overrides> <property name="foo:documentDate"> <mandatory>true</mandatory> </property> </overrides> </type> </types>
this one will not enforce foo:documentDate on the type foo:child
<types> <type name="foo:parent"> … <properties> <property name="foo:documentDate"> <type>d:date</type> <mandatory enforced="false">false</mandatory> <multiple>false</multiple> </property> </properties> </type> <!– Rechnung –> <type name="foo:child"> … <overrides> <property name="foo:documentDate"> <mandatory>true</mandatory> </property> </overrides> </type> </types>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2014 04:25 AM
In your parent type you define <strong>mandatory is false </strong>but <strong>mandatory enforced is true</strong>,it is meaningless. once you set
mandatory to false
it would be useless to set mandatory enforced to true
.So under normal circumstances we will not define our model like thatAs why it happens as you pointed ,here is the reason:
When alfresco complile overrided property ,it will try to enforce both mandatory requirment and mandatory enforced requirment on the
overrided property no matter wether the mandatory comes from parent property definition or comes from overrided property. Doing so it will not take the risk that relax mandatory requirement.
That means for both mandatory and mandatory enforced attribute ,alfresco will set the attribute value to <strong>true </strong> if there is at lease one true in either parent property definition or overrided property
So in your first example parent type's mandatory enforced attribute
enforced="true"
will be inherited by child type,plus child type 's own <mandatory>true</mandatory>
.combine the two give you <overrides> <property name="foo:documentDate"> <mandatory enforced="true">true</mandatory> </property> </overrides>
In your second example, combine parent type's settings and child type's sttings give you
<overrides> <property name="foo:documentDate"> <mandatory enforced="false">true</mandatory> </property> </overrides>
Although it is not a serious bug ,I guess it would be better if alfresco can give us a warning or add some test statements to deal with this problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2014 04:26 AM
In your parent type you define <strong>mandatory is false </strong>but <strong>mandatory enforced is true</strong>,it is meaningless. once you set
mandatory to false
it would be useless to set mandatory enforced to true
.So under normal circumstances we will not define our model like thatAs why it happens as you pointed ,here is the reason:
When alfresco complile overrided property ,it will try to enforce both mandatory requirment and mandatory enforced requirment on the
overrided property no matter wether the mandatory comes from parent property definition or comes from overrided property. Doing so it will not take the risk that relax mandatory requirement.
That means for both mandatory and mandatory enforced attribute ,alfresco will set the attribute value to <strong>true </strong> if there is at lease one true in either parent property definition or overrided property
So in your first example parent type's mandatory enforced attribute
enforced="true"
will be inherited by child type,plus child type 's own <mandatory>true</mandatory>
.combine the two give you <overrides> <property name="foo:documentDate"> <mandatory enforced="true">true</mandatory> </property> </overrides>
In your second example, combine parent type's settings and child type's sttings give you
<overrides> <property name="foo:documentDate"> <mandatory enforced="false">true</mandatory> </property> </overrides>
Although it is not a serious bug ,I guess it would be better if alfresco can give us a warning or add some test statements to deal with this problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2014 01:24 PM
But, as you pointed out, it is "misleading" or at least "not clear" why I would define "enforcement" on a mandatory=false property (In fact: just so my overridden Property has correct enforcement)
And, it has a case, which cant be modeled:
parent: mandatory=false, child1: mandatory=true/enforcement=true, child2: mandatory=true/enforcement=false
(just a hypothetic example, though)
All-in-All: It would be much clearer to allow overriding enforcement on the mandatory tag.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2014 10:55 PM
It is legal to define like below,even if
enforcement=true
is no use for parent type ,but it will be inherited by child type.parent: mandatory=false, enforcement=true
So except necessary ,I think we should define parent type like this
parent: mandatory=false, enforcement=falseor parent: mandatory=true, enforcement=false
Then in child type ,we can set enforcement=true,or just use parent or default value(default value is false).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2014 01:09 AM
and that's the Whole Point: we can't. The XSD will not allow adding "enforcement" attribute to "mandatory" tag!
(see the relevant portion of XSD in my original post)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2014 01:27 AM
But It seems "enforced" attribute is already considered in java class (M2PropertyOverride.java) and m2binding file,it is just ignored in modelSchema.xsd
You can submit a bug in jira,hope they will modify this xsd file and add "enforced" attribute to "mandatory" tag.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2014 02:18 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2014 01:13 AM
