- Resolved issue where title, description and author could be missing, basically when aspect was not applied

- Added ability for transient properties to use standard controls and pick up config

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13740 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2009-03-25 00:12:44 +00:00
parent f8310e39c0
commit 984c87cb0b
3 changed files with 35 additions and 7 deletions

View File

@@ -234,7 +234,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
// check the field definitions
Collection<FieldDefinition> fieldDefs = form.getFieldDefinitions();
assertNotNull("Expecting to find fields", fieldDefs);
assertEquals("Expecting to find 22 fields", 22, fieldDefs.size());
assertEquals("Expecting to find 23 fields", 23, fieldDefs.size());
// create a Map of the field definitions
// NOTE: we can safely do this as we know there are no duplicate field names and we're not

View File

@@ -26,6 +26,7 @@ package org.alfresco.repo.forms.processor;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -222,8 +223,8 @@ public class NodeHandler extends AbstractHandler
{
// get the property definitions for the type of node being persisted
QName type = this.nodeService.getType(nodeRef);
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(
type, this.nodeService.getAspects(nodeRef));
Collection<QName> aspects = this.getAspectsToInclude(nodeRef);
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(type, aspects);
Map<QName, PropertyDefinition> propDefs = typeDef.getProperties();
Map<QName, Serializable> propsToPersist = new HashMap<QName, Serializable>(data.getData().size());
@@ -271,8 +272,8 @@ public class NodeHandler extends AbstractHandler
{
// get data dictionary definition for node
QName type = this.nodeService.getType(nodeRef);
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(
type, this.nodeService.getAspects(nodeRef));
Collection<QName> aspects = this.getAspectsToInclude(nodeRef);
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(type, aspects);
// iterate round the property definitions, create the equivalent
// field definition and setup the data for the property
@@ -736,6 +737,33 @@ public class NodeHandler extends AbstractHandler
}
}
/**
* Returns a Collection of aspects for the given noderef to use
* for generating and persisting the form.
*
* @param nodeRef The NodeRef of the node to get aspects for
* @return The Collection of aspects
*/
protected Collection<QName> getAspectsToInclude(NodeRef nodeRef)
{
List<QName> currentAspects = new ArrayList<QName>();
currentAspects.addAll(this.nodeService.getAspects(nodeRef));
// TODO: make the list of aspects to ensure are present configurable
// make sure the titled and author aspects are present
if (currentAspects.contains(ContentModel.ASPECT_TITLED) == false)
{
currentAspects.add(ContentModel.ASPECT_TITLED);
}
if (currentAspects.contains(ContentModel.ASPECT_AUTHOR) == false)
{
currentAspects.add(ContentModel.ASPECT_AUTHOR);
}
return currentAspects;
}
/**
* Returns a comma separated list string of the given list object.
*

View File

@@ -20,12 +20,12 @@ function testGetFormForContentNode()
var fieldDefs = form.fieldDefinitions;
test.assertNotNull(fieldDefs, "field definitions should not be null.");
test.assertEquals(22, fieldDefs.length);
test.assertEquals(23, fieldDefs.length);
// This dataHash is now an integer-keyed hash of the field definition data objects.
var fieldDefnDataHash = form.fieldDefinitionData;
test.assertNotNull(fieldDefnDataHash, "field definition data should not be null.");
test.assertEquals(22, fieldDefnDataHash.length);
test.assertEquals(23, fieldDefnDataHash.length);
var nameField = getFieldDefnFromMap('cm:name', fieldDefnDataHash);
var titleField = getFieldDefnFromMap('cm:title', fieldDefnDataHash);