mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added sys:incomplete aspect.
Extended <mandatory> definition in the DD. The "mandatory" properties in our system have, until now, been optional, i.e. the integrity has not been enforced. It is possible to have <mandatory enforced="true">true</mandatory>, which means "mandatory and enforced", but <mandatory enforced="false">true</mandatory>, which means "mandatory but not enforced". Our system properties have been marked as "mandatory". Dublin core has had the properties marked as "required". Currently, if the Dublin Core is added, the node is tagged with sys:incomplete. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2562 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -18,12 +18,14 @@ package org.alfresco.repo.dictionary;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.i18n.I18NUtil;
|
||||
import org.alfresco.repo.dictionary.constraint.RegexConstraint;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.ClassDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.Constraint;
|
||||
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
@@ -144,6 +146,42 @@ public class DictionaryDAOTest extends TestCase
|
||||
assertTrue("Expected type REGEX constraint", constraint instanceof RegexConstraint);
|
||||
}
|
||||
|
||||
public void testMandatoryEnforced()
|
||||
{
|
||||
// get the properties for the test type
|
||||
QName testEnforcedQName = QName.createQName(TEST_URL, "enforced");
|
||||
ClassDefinition testEnforcedClassDef = service.getClass(testEnforcedQName);
|
||||
Map<QName, PropertyDefinition> testEnforcedPropertyDefs = testEnforcedClassDef.getProperties();
|
||||
|
||||
PropertyDefinition propertyDef = null;
|
||||
|
||||
QName testMandatoryEnforcedQName = QName.createQName(TEST_URL, "mandatory-enforced");
|
||||
propertyDef = testEnforcedPropertyDefs.get(testMandatoryEnforcedQName);
|
||||
assertNotNull("Property not found: " + testMandatoryEnforcedQName,
|
||||
propertyDef);
|
||||
assertTrue("Expected property to be mandatory: " + testMandatoryEnforcedQName,
|
||||
propertyDef.isMandatory());
|
||||
assertTrue("Expected property to be mandatory-enforced: " + testMandatoryEnforcedQName,
|
||||
propertyDef.isMandatoryEnforced());
|
||||
|
||||
QName testMandatoryNotEnforcedQName = QName.createQName(TEST_URL, "mandatory-not-enforced");
|
||||
propertyDef = testEnforcedPropertyDefs.get(testMandatoryNotEnforcedQName);
|
||||
assertNotNull("Property not found: " + testMandatoryNotEnforcedQName,
|
||||
propertyDef);
|
||||
assertTrue("Expected property to be mandatory: " + testMandatoryNotEnforcedQName,
|
||||
propertyDef.isMandatory());
|
||||
assertFalse("Expected property to be mandatory-not-enforced: " + testMandatoryNotEnforcedQName,
|
||||
propertyDef.isMandatoryEnforced());
|
||||
|
||||
QName testMandatoryDefaultEnforcedQName = QName.createQName(TEST_URL, "mandatory-default-enforced");
|
||||
propertyDef = testEnforcedPropertyDefs.get(testMandatoryDefaultEnforcedQName);
|
||||
assertNotNull("Property not found: " + testMandatoryDefaultEnforcedQName,
|
||||
propertyDef);
|
||||
assertTrue("Expected property to be mandatory: " + testMandatoryDefaultEnforcedQName,
|
||||
propertyDef.isMandatory());
|
||||
assertFalse("Expected property to be mandatory-not-enforced: " + testMandatoryDefaultEnforcedQName,
|
||||
propertyDef.isMandatoryEnforced());
|
||||
}
|
||||
|
||||
public void testSubClassOf()
|
||||
{
|
||||
|
@@ -34,6 +34,7 @@ public class M2Property
|
||||
private String propertyType = null;
|
||||
private boolean isProtected = false;
|
||||
private boolean isMandatory = false;
|
||||
private boolean isMandatoryEnforced = false;
|
||||
private boolean isMultiValued = false;
|
||||
private String defaultValue = null;
|
||||
private boolean isIndexed = true;
|
||||
@@ -118,12 +119,20 @@ public class M2Property
|
||||
return isMandatory;
|
||||
}
|
||||
|
||||
|
||||
public void setMandatory(boolean isMandatory)
|
||||
{
|
||||
this.isMandatory = isMandatory;
|
||||
}
|
||||
|
||||
public boolean isMandatoryEnforced()
|
||||
{
|
||||
return isMandatoryEnforced;
|
||||
}
|
||||
|
||||
public void setMandatoryEnforced(boolean isMandatoryEnforced)
|
||||
{
|
||||
this.isMandatoryEnforced = isMandatoryEnforced;
|
||||
}
|
||||
|
||||
public boolean isMultiValued()
|
||||
{
|
||||
|
@@ -139,15 +139,27 @@ import org.alfresco.service.namespace.QName;
|
||||
property.setDefaultValue(defaultValue == null ? propertyDef.getDefaultValue() : defaultValue);
|
||||
|
||||
// Process Mandatory Value
|
||||
Boolean isMandatory = override.isMandatory();
|
||||
if (isMandatory != null)
|
||||
Boolean isOverrideMandatory = override.isMandatory();
|
||||
boolean isOverrideMandatoryEnforced = override.isMandatoryEnforced();
|
||||
if (isOverrideMandatory != null && propertyDef.isMandatory())
|
||||
{
|
||||
if (propertyDef.isMandatory() == true && isMandatory == false)
|
||||
// the override specified whether the property should be mandatory or not
|
||||
// check that the mandatory enforcement is not relaxed
|
||||
if (!isOverrideMandatory)
|
||||
{
|
||||
throw new DictionaryException("Cannot relax mandatory attribute of property " + propertyDef.getName().toPrefixString());
|
||||
throw new DictionaryException(
|
||||
"d_dictionary.property.err.cannot_relax_mandatory",
|
||||
propertyDef.getName().toPrefixString());
|
||||
}
|
||||
else if (!isOverrideMandatoryEnforced && propertyDef.isMandatoryEnforced())
|
||||
{
|
||||
throw new DictionaryException(
|
||||
"d_dictionary.property.err.cannot_relax_mandatory_enforcement",
|
||||
propertyDef.getName().toPrefixString());
|
||||
}
|
||||
}
|
||||
property.setMandatory(isMandatory == null ? propertyDef.isMandatory() : isMandatory);
|
||||
property.setMandatory(isOverrideMandatory == null ? propertyDef.isMandatory() : isOverrideMandatory);
|
||||
property.setMandatoryEnforced(isOverrideMandatoryEnforced);
|
||||
|
||||
// Copy all other properties as they are
|
||||
property.setDescription(propertyDef.getDescription());
|
||||
@@ -260,7 +272,11 @@ import org.alfresco.service.namespace.QName;
|
||||
return m2Property.isMandatory();
|
||||
}
|
||||
|
||||
|
||||
public boolean isMandatoryEnforced()
|
||||
{
|
||||
return m2Property.isMandatoryEnforced();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.dictionary.PropertyDefinition#isProtected()
|
||||
*/
|
||||
|
@@ -27,6 +27,7 @@ public class M2PropertyOverride
|
||||
{
|
||||
private String name;
|
||||
private Boolean isMandatory;
|
||||
private boolean isMandatoryEnforced = false;
|
||||
private String defaultValue;
|
||||
|
||||
|
||||
@@ -58,6 +59,10 @@ public class M2PropertyOverride
|
||||
this.isMandatory = isMandatory;
|
||||
}
|
||||
|
||||
public boolean isMandatoryEnforced()
|
||||
{
|
||||
return isMandatoryEnforced;
|
||||
}
|
||||
|
||||
public String getDefaultValue()
|
||||
{
|
||||
|
@@ -121,16 +121,31 @@
|
||||
|
||||
<type name="test:folder">
|
||||
<parent>test:base</parent>
|
||||
|
||||
<properties>
|
||||
<property name="test:folderprop">
|
||||
<type>d:text</type>
|
||||
<protected>true</protected>
|
||||
<default></default>
|
||||
</property>
|
||||
|
||||
</properties>
|
||||
|
||||
</type>
|
||||
|
||||
<type name="test:enforced">
|
||||
<parent>test:base</parent>
|
||||
<properties>
|
||||
<property name="test:mandatory-enforced">
|
||||
<type>d:text</type>
|
||||
<mandatory enforced="true">true</mandatory>
|
||||
</property>
|
||||
<property name="test:mandatory-not-enforced">
|
||||
<type>d:text</type>
|
||||
<mandatory enforced="false">true</mandatory>
|
||||
</property>
|
||||
<property name="test:mandatory-default-enforced">
|
||||
<type>d:text</type>
|
||||
<mandatory>true</mandatory>
|
||||
</property>
|
||||
</properties>
|
||||
</type>
|
||||
|
||||
</types>
|
||||
|
@@ -71,7 +71,10 @@
|
||||
<collection field="propertyOverrides" item-type="org.alfresco.repo.dictionary.M2PropertyOverride" factory="org.alfresco.repo.dictionary.M2Model.createList">
|
||||
<structure name="property" type="org.alfresco.repo.dictionary.M2PropertyOverride" usage="optional">
|
||||
<value style="attribute" name="name" field="name"/>
|
||||
<value name="mandatory" field="isMandatory" usage="optional"/>
|
||||
<structure name="mandatory" usage="optional">
|
||||
<value style="attribute" name="enforced" field="isMandatoryEnforced" usage="optional" />
|
||||
<value style="text" field="isMandatory" />
|
||||
</structure>
|
||||
<value name="default" field="defaultValue" usage="optional"/>
|
||||
</structure>
|
||||
</collection>
|
||||
@@ -97,7 +100,10 @@
|
||||
<value name="description" field="description" usage="optional"/>
|
||||
<value name="type" field="propertyType"/>
|
||||
<value name="protected" field="isProtected" usage="optional"/>
|
||||
<value name="mandatory" field="isMandatory" usage="optional"/>
|
||||
<structure name="mandatory" usage="optional">
|
||||
<value style="attribute" name="enforced" field="isMandatoryEnforced" usage="optional"/>
|
||||
<value style="text" field="isMandatory" />
|
||||
</structure>
|
||||
<value name="multiple" field="isMultiValued" usage="optional"/>
|
||||
<value name="default" field="defaultValue" usage="optional"/>
|
||||
<structure name="index" usage="optional">
|
||||
|
Reference in New Issue
Block a user