mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
implementing enforcement of repeat constraints. this is not being done in a correct way - but it's good enough for this release. while in xml schema you are limited to simple maximum and minimum constraints for repeats, xforms is a lot more flexible and allows an xpath expression to be used. interpreting this single constraint to determine whether the repeat is at a maximum or minimum is rather difficult - much less interpreting it for arbitrary constraints. for this release, i'm adding maximum and minimum to the bind element in the alfresco namespace and using them from the client. chiba still uses the xpath expression to manage the constraint - but ultimately for now both yield the same results.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4502 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2603,6 +2603,7 @@ public class SchemaFormBuilder
|
||||
namespaces.put(SchemaFormBuilder.XLINK_NS_PREFIX, SchemaFormBuilder.XLINK_NS);
|
||||
namespaces.put(SchemaFormBuilder.XMLEVENTS_NS_PREFIX, SchemaFormBuilder.XMLEVENTS_NS);
|
||||
namespaces.put(SchemaFormBuilder.XMLSCHEMA_INSTANCE_NS_PREFIX, SchemaFormBuilder.XMLSCHEMA_INSTANCE_NS);
|
||||
namespaces.put(SchemaFormBuilder.ALFRESCO_NS_PREFIX, SchemaFormBuilder.ALFRESCO_NS);
|
||||
for (String nsPrefix : namespaces.keySet())
|
||||
{
|
||||
this.addNamespace(envelopeElement, nsPrefix, namespaces.get(nsPrefix));
|
||||
@@ -3202,12 +3203,23 @@ public class SchemaFormBuilder
|
||||
String maxConstraint = null;
|
||||
|
||||
if (o.minimum > 1)
|
||||
{
|
||||
//if 0 or 1 -> no constraint (managed by "required")
|
||||
minConstraint = "count(.) >= " + o.minimum;
|
||||
bindElement.setAttributeNS(ALFRESCO_NS,
|
||||
ALFRESCO_NS_PREFIX + "minimum",
|
||||
String.valueOf(o.minimum));
|
||||
}
|
||||
|
||||
if (o.maximum > 1)
|
||||
{
|
||||
//if 1 or unbounded -> no constraint
|
||||
maxConstraint = "count(.) <= " + o.maximum;
|
||||
bindElement.setAttributeNS(ALFRESCO_NS,
|
||||
ALFRESCO_NS_PREFIX + "maximum",
|
||||
String.valueOf(o.maximum));
|
||||
|
||||
}
|
||||
|
||||
final String constraint = (minConstraint != null && maxConstraint != null
|
||||
? minConstraint + " and " + maxConstraint
|
||||
|
Reference in New Issue
Block a user