mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- 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:
@@ -234,7 +234,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest
|
|||||||
// check the field definitions
|
// check the field definitions
|
||||||
Collection<FieldDefinition> fieldDefs = form.getFieldDefinitions();
|
Collection<FieldDefinition> fieldDefs = form.getFieldDefinitions();
|
||||||
assertNotNull("Expecting to find fields", fieldDefs);
|
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
|
// 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
|
// NOTE: we can safely do this as we know there are no duplicate field names and we're not
|
||||||
|
@@ -26,6 +26,7 @@ package org.alfresco.repo.forms.processor;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -222,8 +223,8 @@ public class NodeHandler extends AbstractHandler
|
|||||||
{
|
{
|
||||||
// get the property definitions for the type of node being persisted
|
// get the property definitions for the type of node being persisted
|
||||||
QName type = this.nodeService.getType(nodeRef);
|
QName type = this.nodeService.getType(nodeRef);
|
||||||
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(
|
Collection<QName> aspects = this.getAspectsToInclude(nodeRef);
|
||||||
type, this.nodeService.getAspects(nodeRef));
|
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(type, aspects);
|
||||||
Map<QName, PropertyDefinition> propDefs = typeDef.getProperties();
|
Map<QName, PropertyDefinition> propDefs = typeDef.getProperties();
|
||||||
|
|
||||||
Map<QName, Serializable> propsToPersist = new HashMap<QName, Serializable>(data.getData().size());
|
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
|
// get data dictionary definition for node
|
||||||
QName type = this.nodeService.getType(nodeRef);
|
QName type = this.nodeService.getType(nodeRef);
|
||||||
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(
|
Collection<QName> aspects = this.getAspectsToInclude(nodeRef);
|
||||||
type, this.nodeService.getAspects(nodeRef));
|
TypeDefinition typeDef = this.dictionaryService.getAnonymousType(type, aspects);
|
||||||
|
|
||||||
// iterate round the property definitions, create the equivalent
|
// iterate round the property definitions, create the equivalent
|
||||||
// field definition and setup the data for the property
|
// 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.
|
* Returns a comma separated list string of the given list object.
|
||||||
*
|
*
|
||||||
|
@@ -20,12 +20,12 @@ function testGetFormForContentNode()
|
|||||||
|
|
||||||
var fieldDefs = form.fieldDefinitions;
|
var fieldDefs = form.fieldDefinitions;
|
||||||
test.assertNotNull(fieldDefs, "field definitions should not be null.");
|
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.
|
// This dataHash is now an integer-keyed hash of the field definition data objects.
|
||||||
var fieldDefnDataHash = form.fieldDefinitionData;
|
var fieldDefnDataHash = form.fieldDefinitionData;
|
||||||
test.assertNotNull(fieldDefnDataHash, "field definition data should not be null.");
|
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 nameField = getFieldDefnFromMap('cm:name', fieldDefnDataHash);
|
||||||
var titleField = getFieldDefnFromMap('cm:title', fieldDefnDataHash);
|
var titleField = getFieldDefnFromMap('cm:title', fieldDefnDataHash);
|
||||||
|
Reference in New Issue
Block a user