From 778078e26c9b1f02d12eefe4f712dd07cbfd7037 Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Tue, 28 Sep 2010 09:35:45 +0000 Subject: [PATCH] Fixed ALF-4751 (When starting a workflow with no form configuration duplicated fields are seen), ALF-4859 (Lifecycle review and approve form is incorrect) & ALF-4649 (Node based forms render a form containing system properties when no configuration is present) The set of default fields for each type of form processor has been updated, default node and type forms now don't return the 'sys' properties previously seen, a default task form no longer returns the identifier field and a default workflow form no longer returns the task level description, priority and due date fields. Also completed a coding standards and comments sweep across all forms code. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22734 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repo/forms/FormServiceImplTest.java | 19 ++++- .../processor/AbstractFieldProcessor.java | 1 + .../repo/forms/processor/FieldProcessor.java | 3 +- .../processor/FieldProcessorRegistry.java | 12 ++- .../processor/FilteredFormProcessor.java | 5 +- .../forms/processor/FormCreationData.java | 4 +- .../forms/processor/FormCreationDataImpl.java | 3 + .../repo/forms/processor/FormPersister.java | 1 + .../processor/FormProcessorRegistry.java | 2 +- .../node/AssociationFieldProcessor.java | 3 +- .../processor/node/ContentModelField.java | 2 + .../ContentModelFieldProcessorRegistry.java | 2 +- .../node/ContentModelFormProcessor.java | 61 ++++++++------- .../processor/node/DefaultFieldBuilder.java | 9 +-- .../processor/node/DefaultFieldProcessor.java | 3 +- .../node/EncodingFieldProcessor.java | 3 +- .../repo/forms/processor/node/FieldUtils.java | 78 +++++++++++++++++-- .../node/MimetypeFieldProcessor.java | 9 ++- .../node/MockClassAttributeDefinition.java | 64 +++++---------- .../node/MockFieldProcessorRegistry.java | 2 +- .../processor/node/NodeFormProcessor.java | 36 +++------ .../node/PropertyFieldProcessor.java | 5 +- .../processor/node/QNameFieldProcessor.java | 2 + .../processor/node/SizeFieldProcessor.java | 4 +- .../node/TransientFieldProcessor.java | 3 +- .../processor/node/TransientValueGetter.java | 3 +- .../processor/node/TypeFormProcessor.java | 35 +++------ .../AbstractWorkflowFormProcessor.java | 40 ++++++---- .../workflow/ContentModelFormPersister.java | 25 +++--- .../forms/processor/workflow/DataKeyInfo.java | 2 +- .../processor/workflow/DataKeyMatcher.java | 6 +- .../forms/processor/workflow/FieldType.java | 2 +- .../processor/workflow/FormPersister.java | 3 +- .../workflow/TransitionFieldProcessor.java | 3 +- .../workflow/TypedPropertyValueGetter.java | 4 +- .../workflow/WorkflowFormPersister.java | 4 +- .../workflow/WorkflowFormProcessor.java | 30 ++++++- .../workflow/WorkflowFormProcessorTest.java | 12 ++- .../repo/forms/script/test_formService.js | 4 +- .../repo/workflow/WorkflowBuilder.java | 6 +- 40 files changed, 300 insertions(+), 215 deletions(-) diff --git a/source/java/org/alfresco/repo/forms/FormServiceImplTest.java b/source/java/org/alfresco/repo/forms/FormServiceImplTest.java index 860ab5c4a3..be4277ff52 100644 --- a/source/java/org/alfresco/repo/forms/FormServiceImplTest.java +++ b/source/java/org/alfresco/repo/forms/FormServiceImplTest.java @@ -263,7 +263,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest // check the field definitions Collection fieldDefs = form.getFieldDefinitions(); assertNotNull("Expecting to find fields", fieldDefs); - assertEquals("Expecting to find 22 fields", 22, fieldDefs.size()); + assertEquals("Expecting to find 18 fields", 18, 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 @@ -302,6 +302,12 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertNotNull("Expecting to find the cm:sentdate field", sentDateField); assertNotNull("Expecting to find the cm:references field", referencesField); + // check the system properties are not present by default + assertFalse(fieldDefMap.containsKey("sys:node-dbid")); + assertFalse(fieldDefMap.containsKey("sys:store-identifier")); + assertFalse(fieldDefMap.containsKey("sys:node-uuid")); + assertFalse(fieldDefMap.containsKey("sys:store-protocol")); + // check the labels of all the fields assertEquals("Expecting cm:name label to be " + LABEL_NAME, LABEL_NAME, nameField.getLabel()); @@ -655,7 +661,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest // check the field definitions Collection fieldDefs = form.getFieldDefinitions(); assertNotNull("Expecting to find fields", fieldDefs); - assertEquals("Expecting to find 11 fields", 11, fieldDefs.size()); + assertEquals("Expecting to find 7 fields", 7, 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 @@ -674,6 +680,12 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest assertNotNull("Expecting to find the cm:name field", nameField); assertNotNull("Expecting to find the cm:contains field", containsField); + // check the system properties are not present by default + assertFalse(fieldDefMap.containsKey("sys:node-dbid")); + assertFalse(fieldDefMap.containsKey("sys:store-identifier")); + assertFalse(fieldDefMap.containsKey("sys:node-uuid")); + assertFalse(fieldDefMap.containsKey("sys:store-protocol")); + // check the labels of all the fields assertEquals("Expecting cm:name label to be " + LABEL_NAME, LABEL_NAME, nameField.getLabel()); @@ -828,7 +840,7 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest // check the field definitions Collection fieldDefs = form.getFieldDefinitions(); assertNotNull("Expecting to find fields", fieldDefs); - assertEquals("Expecting to find 11 fields", 11, fieldDefs.size()); + assertEquals("Expecting to find 7 fields", 7, 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 @@ -1301,7 +1313,6 @@ public class FormServiceImplTest extends BaseAlfrescoSpringTest private List getExpectedTaskFields() { ArrayList fields = new ArrayList(4); - fields.add(WorkflowModel.PROP_TASK_ID.toPrefixString(namespaceService)); fields.add(WorkflowModel.PROP_DESCRIPTION.toPrefixString(namespaceService)); fields.add(WorkflowModel.PROP_STATUS.toPrefixString(namespaceService)); fields.add(WorkflowModel.PROP_PRIORITY.toPrefixString(namespaceService)); diff --git a/source/java/org/alfresco/repo/forms/processor/AbstractFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/AbstractFieldProcessor.java index d823f8dadf..b6d14cb240 100644 --- a/source/java/org/alfresco/repo/forms/processor/AbstractFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/AbstractFieldProcessor.java @@ -24,6 +24,7 @@ import org.alfresco.repo.forms.FormException; import org.apache.commons.logging.Log; /** + * Abstract base class for all field processors. * * @since 3.4 * @author Nick Smith diff --git a/source/java/org/alfresco/repo/forms/processor/FieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/FieldProcessor.java index 156c1b1c36..0d74ba7bd9 100644 --- a/source/java/org/alfresco/repo/forms/processor/FieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/FieldProcessor.java @@ -22,13 +22,12 @@ package org.alfresco.repo.forms.processor; import org.alfresco.repo.forms.Field; /** + * Interface definition for a field processor. * * @since 3.4 * @author Nick Smith - * */ public interface FieldProcessor { Field generateField(String fieldName, FormCreationData data); - } diff --git a/source/java/org/alfresco/repo/forms/processor/FieldProcessorRegistry.java b/source/java/org/alfresco/repo/forms/processor/FieldProcessorRegistry.java index ce75440fcc..435398e8a1 100644 --- a/source/java/org/alfresco/repo/forms/processor/FieldProcessorRegistry.java +++ b/source/java/org/alfresco/repo/forms/processor/FieldProcessorRegistry.java @@ -25,9 +25,11 @@ import java.util.Map; import org.alfresco.repo.forms.Field; /** + * Holds a FieldProcessor implementation for the fields that can be processed by + * the FormProcessor. + * * @since 3.4 * @author Nick Smith - * */ public class FieldProcessorRegistry { @@ -58,7 +60,6 @@ public class FieldProcessorRegistry return processors.get(key); } - /** * Attempts to build a {@link Field}. The method first tries to derive a key from the fieldname, then uses this key to look up a {@link FieldProcessor}. * This {@link FieldProcessor} is then used to generate a {@link Field}. @@ -76,6 +77,12 @@ public class FieldProcessorRegistry return fieldProcessor.generateField(fieldName, data); } + /** + * Returns a FieldProcessor for the given field name. + * + * @param fieldName + * @return The FieldProcessor implementation for the field or null if there isn't one regsitered. + */ protected FieldProcessor getFieldProcessor(String fieldName) { FieldProcessor fieldProcessor = get(getKey(fieldName)); @@ -107,6 +114,7 @@ public class FieldProcessorRegistry } /** + * Sets the default field processor instance. * @param defaultProcessor the defaultProcessor to set */ public void setDefaultProcessor(FieldProcessor defaultProcessor) diff --git a/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java index 0efb200c57..ab5b8b704a 100644 --- a/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/FilteredFormProcessor.java @@ -191,8 +191,11 @@ public abstract class FilteredFormProcessor extends Abstr private List getIgnoredFields() { - if(ignoredFields != null) + if (ignoredFields != null) + { return ignoredFields; + } + return getDefaultIgnoredFields(); } diff --git a/source/java/org/alfresco/repo/forms/processor/FormCreationData.java b/source/java/org/alfresco/repo/forms/processor/FormCreationData.java index b4ea379b8a..9b0d47bc9f 100644 --- a/source/java/org/alfresco/repo/forms/processor/FormCreationData.java +++ b/source/java/org/alfresco/repo/forms/processor/FormCreationData.java @@ -28,7 +28,9 @@ package org.alfresco.repo.forms.processor; import java.util.Map; /** - * Simple DTO containing various objects needed to generate Forms. + * Interface definition for a simple DTO containing various objects + * needed to generate Forms. + * * @since 3.4 * @author Nick Smith */ diff --git a/source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java b/source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java index 3ddac4da8b..7ee2d12f55 100644 --- a/source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java +++ b/source/java/org/alfresco/repo/forms/processor/FormCreationDataImpl.java @@ -67,7 +67,10 @@ public class FormCreationDataImpl implements FormCreationData public boolean isForcedField(String fieldName) { if (forcedFields == null) + { return false; + } + return forcedFields.contains(fieldName); } diff --git a/source/java/org/alfresco/repo/forms/processor/FormPersister.java b/source/java/org/alfresco/repo/forms/processor/FormPersister.java index 2b5d14e8b8..18bf8cee5d 100644 --- a/source/java/org/alfresco/repo/forms/processor/FormPersister.java +++ b/source/java/org/alfresco/repo/forms/processor/FormPersister.java @@ -20,6 +20,7 @@ package org.alfresco.repo.forms.processor; /** + * Interface definition for a helper class that handles persisting form data. * * @since 3.4 * @author Nick Smith diff --git a/source/java/org/alfresco/repo/forms/processor/FormProcessorRegistry.java b/source/java/org/alfresco/repo/forms/processor/FormProcessorRegistry.java index 4111aae383..2256935744 100644 --- a/source/java/org/alfresco/repo/forms/processor/FormProcessorRegistry.java +++ b/source/java/org/alfresco/repo/forms/processor/FormProcessorRegistry.java @@ -27,7 +27,7 @@ import org.apache.commons.logging.LogFactory; /** * Holds a FormProcessor implementation for each of the types of form that - * can be processed. By default a node, task and XML schema form processor + * can be processed. By default a node, type, task, and workflow form processor * are available. *

* Given an item the registry selects the relevant form processor, the match diff --git a/source/java/org/alfresco/repo/forms/processor/node/AssociationFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/AssociationFieldProcessor.java index c2cc5870c9..e347819aa0 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/AssociationFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/AssociationFieldProcessor.java @@ -12,6 +12,7 @@ import org.alfresco.repo.forms.AssociationFieldDefinition; import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.FieldGroup; import org.alfresco.repo.forms.AssociationFieldDefinition.Direction; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.namespace.NamespaceService; @@ -20,10 +21,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** + * {@link FieldProcessor} implementation that handles associations. * * @since 3.4 * @author Nick Smith - * */ public class AssociationFieldProcessor extends QNameFieldProcessor { diff --git a/source/java/org/alfresco/repo/forms/processor/node/ContentModelField.java b/source/java/org/alfresco/repo/forms/processor/node/ContentModelField.java index 4ada8cb870..0f46ddb3de 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/ContentModelField.java +++ b/source/java/org/alfresco/repo/forms/processor/node/ContentModelField.java @@ -29,6 +29,8 @@ import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.namespace.QName; /** + * DTO for a content model based Field. + * * @author Nick Smith * @since 3.4 */ diff --git a/source/java/org/alfresco/repo/forms/processor/node/ContentModelFieldProcessorRegistry.java b/source/java/org/alfresco/repo/forms/processor/node/ContentModelFieldProcessorRegistry.java index c5dcda1add..a0d492844e 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/ContentModelFieldProcessorRegistry.java +++ b/source/java/org/alfresco/repo/forms/processor/node/ContentModelFieldProcessorRegistry.java @@ -22,10 +22,10 @@ package org.alfresco.repo.forms.processor.node; import org.alfresco.repo.forms.processor.FieldProcessorRegistry; /** + * FieldProcessorRegistry that exclusively handles content model based field processors. * * @since 3.4 * @author Nick Smith - * */ public class ContentModelFieldProcessorRegistry extends FieldProcessorRegistry { diff --git a/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java index 88a97bbc9f..c006b296dd 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/ContentModelFormProcessor.java @@ -164,7 +164,7 @@ public abstract class ContentModelFormProcessor extends protected void addPropertyDataIfRequired(QName propName, Form form, ContentModelItemData itemData) { String dataKey = makePropDataKey(propName); - if(form.dataExists(dataKey)== false) + if (form.dataExists(dataKey) == false) { PropertyFieldProcessor processor = new PropertyFieldProcessor(namespaceService, dictionaryService); Object value = processor.getValue(propName, itemData); @@ -200,6 +200,19 @@ public abstract class ContentModelFormProcessor extends Map transientValues = getTransientValues(item); return new ContentModelItemData(item, propDefs, assocDefs, propValues, assocValues, transientValues); } + + protected List getDefaultIgnoredFields() + { + ArrayList fields = new ArrayList(8); + + // ignore system properties by default + fields.add("sys:node-dbid"); + fields.add("sys:store-identifier"); + fields.add("sys:node-uuid"); + fields.add("sys:store-protocol"); + + return fields; + } protected Set getAspectNames(ItemType item) { @@ -374,8 +387,7 @@ public abstract class ContentModelFormProcessor extends } else if (propDef.getDataType().getName().equals(DataTypeDefinition.BOOLEAN)) { - // check for browser representation of true, that being - // "on" + // check for browser representation of true, that being "on" if (value instanceof String && ON.equals(value)) { value = Boolean.TRUE; @@ -419,8 +431,7 @@ public abstract class ContentModelFormProcessor extends } else if (getLogger().isWarnEnabled()) { - getLogger().warn( - "Ignoring field '" + fieldData.getName() + "' as a property definition can not be found"); + getLogger().warn("Ignoring field '" + fieldData.getName() + "' as a property definition can not be found"); } } else @@ -442,8 +453,7 @@ public abstract class ContentModelFormProcessor extends } else if (fieldName.equals(SizeFieldProcessor.KEY)) { - // the size property is well known but should never be - // persisted + // the size property is well known but should never be persisted // as it is calculated so this is intentionally ignored } else if (getLogger().isWarnEnabled()) @@ -482,20 +492,14 @@ public abstract class ContentModelFormProcessor extends QName fullQName = QName.createQName(qNamePrefix, localName, namespaceService); - // ensure that the association being persisted is defined in the - // model + // ensure that the association being persisted is defined in the model AssociationDefinition assocDef = assocDefs.get(fullQName); - // TODO: if the association is not defined on the node, check for - // the association - // in all models, however, the source of an association can be - // critical so we - // can't just look up the association in the model regardless. We - // need to - // either check the source class of the node and the assoc def match - // or we - // check that the association was defined as part of an aspect - // (where by it's + // TODO: if the association is not defined on the node, check for the association + // in all models, however, the source of an association can be critical so we + // can't just look up the association in the model regardless. We need to + // either check the source class of the node and the assoc def match or we + // check that the association was defined as part of an aspect (where by it's // nature can have any source type) if (assocDef == null) @@ -511,8 +515,7 @@ public abstract class ContentModelFormProcessor extends String value = (String) fieldData.getValue(); String[] nodeRefs = value.split(","); - // Each element in this array will be a new target node in - // association + // Each element in this array will be a new target node in association // with the current node. for (String nextTargetNode : nodeRefs) { @@ -529,7 +532,8 @@ public abstract class ContentModelFormProcessor extends } else { - assocCommands.add(new AddAssocCommand(nodeRef, new NodeRef(nextTargetNode), fullQName)); + assocCommands.add(new AddAssocCommand(nodeRef, new NodeRef(nextTargetNode), + fullQName)); } } else if (assocSuffix.equals(ASSOC_DATA_REMOVED_SUFFIX)) @@ -588,8 +592,7 @@ public abstract class ContentModelFormProcessor extends try { // if the name property changes the rename method of the file folder - // service should be called rather than updating the property - // directly + // service should be called rather than updating the property directly this.fileFolderService.rename(nodeRef, (String) fieldData.getValue()); } catch (FileExistsException fee) @@ -859,8 +862,7 @@ class RemoveAssocCommand extends AbstractAssocCommand } /** - * A class representing a request to add a new child association between two - * nodes. + * A class representing a request to add a new child association between two nodes. * * @author Neil McErlean */ @@ -889,16 +891,15 @@ class AddChildAssocCommand extends AbstractAssocCommand return; } } - // We are following the behaviour of the JSF client here in using the - // same + + // We are following the behaviour of the JSF client here in using the same // QName value for the 3rd and 4th parameters in the below call. nodeService.addChild(sourceNodeRef, targetNodeRef, assocQName, assocQName); } } /** - * A class representing a request to remove a child association between two - * nodes. + * A class representing a request to remove a child association between two nodes. * * @author Neil McErlean */ diff --git a/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldBuilder.java b/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldBuilder.java index af6aa4275b..c9e260ab4e 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldBuilder.java +++ b/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldBuilder.java @@ -34,10 +34,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** + * Helper class for building the default fields for a form where an explicit + * set of fields was not provided. * * @since 3.4 * @author Nick Smith - * */ public class DefaultFieldBuilder { @@ -76,10 +77,6 @@ public class DefaultFieldBuilder this.ItemData = (ContentModelItemData) formData.getItemData(); } - /** - * @param ignoredTransientFields2 - * @return - */ private List getNonNullList(List list) { return list == null ? Collections.emptyList() : list; @@ -104,7 +101,7 @@ public class DefaultFieldBuilder List fields = new ArrayList(names.size()); for (QName name : names) { - if(ignoreQName(name)==false) + if (ignoreQName(name) == false) { fields.add(buildPropertyField(name)); } diff --git a/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldProcessor.java index 01994c7d6e..ec7e58b114 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/DefaultFieldProcessor.java @@ -21,6 +21,7 @@ package org.alfresco.repo.forms.processor.node; import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.FieldGroup; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.service.cmr.dictionary.ClassAttributeDefinition; import org.alfresco.service.namespace.QName; import org.alfresco.util.ParameterCheck; @@ -29,10 +30,10 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.InitializingBean; /** + * Default {@link FieldProcessor} implementation, used when an explicit FieldProcessor can not be located. * * @since 3.4 * @author Nick Smith - * */ public class DefaultFieldProcessor extends QNameFieldProcessor implements InitializingBean { diff --git a/source/java/org/alfresco/repo/forms/processor/node/EncodingFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/EncodingFieldProcessor.java index eac57f29cf..5794829133 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/EncodingFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/EncodingFieldProcessor.java @@ -23,16 +23,17 @@ import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DAT import org.alfresco.repo.forms.FieldDefinition; import org.alfresco.repo.forms.PropertyFieldDefinition; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; /** + * {@link FieldProcessor} implementation representing the encoding transient field. * * @since 3.4 * @author Nick Smith - * */ public class EncodingFieldProcessor extends TransientFieldProcessor { diff --git a/source/java/org/alfresco/repo/forms/processor/node/FieldUtils.java b/source/java/org/alfresco/repo/forms/processor/node/FieldUtils.java index 0c8f4c7a2f..c5866e8931 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/FieldUtils.java +++ b/source/java/org/alfresco/repo/forms/processor/node/FieldUtils.java @@ -41,17 +41,33 @@ import org.alfresco.service.namespace.NamespaceService; */ public class FieldUtils { - + /** + * Generates a property field. + * + * @param propDef The definition of the property to generate + * @param value The value of the field + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return The generated Field object + */ public static Field makePropertyField( - PropertyDefinition property, + PropertyDefinition propDef, Object value, FieldGroup group, NamespaceService namespaceService) { PropertyFieldProcessor processor = new PropertyFieldProcessor(namespaceService, null); - return processor.makeField(property, value, group); + return processor.makeField(propDef, value, group); } + /** + * Generates a list of property fields without values. + * + * @param propDefs List of property defintions to create + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return List of generated Field objects + */ public static List makePropertyFields( Collection propDefs, FieldGroup group, @@ -60,6 +76,14 @@ public class FieldUtils return makePropertyFields(propDefs, null, group, namespaceService); } + /** + * Generates a list of property fields with values. + * + * @param propDefAndValue Map of property definitions and corresponding values + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return List of generated Field objects + */ public static List makePropertyFields( Map propDefAndValue, FieldGroup group, @@ -68,6 +92,15 @@ public class FieldUtils return makePropertyFields(propDefAndValue.keySet(), propDefAndValue, group, namespaceService); } + /** + * Generates a list of property fields with values. + * + * @param propDefs List of property definitions to generate + * @param values Map containing the values to use for each property + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return List of generated Field objects + */ public static List makePropertyFields( Collection propDefs, Map values, @@ -78,13 +111,22 @@ public class FieldUtils ArrayList fields = new ArrayList(propDefs.size()); for (PropertyDefinition propDef : propDefs) { - Object value = values==null?null:values.get(propDef); + Object value = values == null ? null : values.get(propDef); Field field = processor.makeField(propDef, value, group); fields.add(field); } return fields; } + /** + * Generates an asssociation field. + * + * @param assocDef The definition of the association to generate + * @param value The value of the field + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return The generated Field object + */ public static Field makeAssociationField( AssociationDefinition assocDef, Object value, @@ -95,7 +137,14 @@ public class FieldUtils return processor.makeField(assocDef, value, group); } - + /** + * Generates a list of association fields without values. + * + * @param assocDefs List of association defintions to create + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return List of generated Field objects + */ public static List makeAssociationFields( Collection assocDefs, FieldGroup group, @@ -104,6 +153,14 @@ public class FieldUtils return makeAssociationFields(assocDefs, null, group, namespaceService); } + /** + * Generates a list of association fields with values. + * + * @param assocDefAndValue Map of association definitions and corresponding values + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return List of generated Field objects + */ public static List makeAssociationFields( Map assocDefAndValue, FieldGroup group, @@ -112,6 +169,15 @@ public class FieldUtils return makeAssociationFields(assocDefAndValue.keySet(), assocDefAndValue, group, namespaceService); } + /** + * Generates a list of association fields with values. + * + * @param assocDefs List of association definitions to generate + * @param values Map containing the values to use for each property + * @param group The group the field belongs to + * @param namespaceService NamespaceService instance + * @return List of generated Field objects + */ public static List makeAssociationFields( Collection assocDefs, Map values, @@ -122,7 +188,7 @@ public class FieldUtils ArrayList fields = new ArrayList(assocDefs.size()); for (AssociationDefinition propDef : assocDefs) { - Object value = values==null?null:values.get(propDef); + Object value = values == null ? null : values.get(propDef); Field field = processor.makeField(propDef, value, group); fields.add(field); } diff --git a/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java index 7a16e25c84..b8ce5fb9d7 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/MimetypeFieldProcessor.java @@ -23,16 +23,17 @@ import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DAT import org.alfresco.repo.forms.FieldDefinition; import org.alfresco.repo.forms.PropertyFieldDefinition; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; /** + * {@link FieldProcessor} implementation representing the mimetype transient field. * * @since 3.4 * @author Nick Smith - * */ public class MimetypeFieldProcessor extends TransientFieldProcessor { @@ -44,12 +45,14 @@ public class MimetypeFieldProcessor extends TransientFieldProcessor private static final String MSG_MIMETYPE_DESC = "form_service.mimetype.description"; @Override - protected Log getLogger() { + protected Log getLogger() + { return logger; } @Override - protected FieldDefinition makeTransientFieldDefinition() { + protected FieldDefinition makeTransientFieldDefinition() + { String dataKeyName = PROP_DATA_PREFIX + KEY; PropertyFieldDefinition mimetypeField = new PropertyFieldDefinition(KEY, DataTypeDefinition.TEXT .getLocalName()); diff --git a/source/java/org/alfresco/repo/forms/processor/node/MockClassAttributeDefinition.java b/source/java/org/alfresco/repo/forms/processor/node/MockClassAttributeDefinition.java index fbc2a17f04..ef816ac20f 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/MockClassAttributeDefinition.java +++ b/source/java/org/alfresco/repo/forms/processor/node/MockClassAttributeDefinition.java @@ -40,10 +40,10 @@ import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.namespace.QName; /** + * Mock implementation of the repository ClassDefinition. * * @since 3.4 * @author Nick Smith - * */ public class MockClassAttributeDefinition implements PropertyDefinition, AssociationDefinition { @@ -139,8 +139,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#getConstraints() + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#getConstraints() */ public List getConstraints() { @@ -148,8 +147,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#getContainerClass + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#getContainerClass * () */ public ClassDefinition getContainerClass() @@ -166,8 +164,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#getDefaultValue() + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#getDefaultValue() */ public String getDefaultValue() { @@ -175,8 +172,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#getDescription() + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#getDescription() */ public String getDescription() { @@ -184,8 +180,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @seeorg.alfresco.service.cmr.dictionary.PropertyDefinition# - * getIndexTokenisationMode() + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#getIndexTokenisationMode() */ public IndexTokenisationMode getIndexTokenisationMode() { @@ -225,9 +220,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#isIndexedAtomically - * () + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#isIndexedAtomically() */ public boolean isIndexedAtomically() { @@ -243,9 +236,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#isMandatoryEnforced - * () + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#isMandatoryEnforced() */ public boolean isMandatoryEnforced() { @@ -253,8 +244,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#isMultiValued() + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#isMultiValued() */ public boolean isMultiValued() { @@ -278,8 +268,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.PropertyDefinition#isStoredInIndex() + * @see org.alfresco.service.cmr.dictionary.PropertyDefinition#isStoredInIndex() */ public boolean isStoredInIndex() { @@ -287,9 +276,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#getSourceClass - * () + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#getSourceClass() */ public ClassDefinition getSourceClass() { @@ -297,9 +284,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#getSourceRoleName - * () + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#getSourceRoleName() */ public QName getSourceRoleName() { @@ -307,9 +292,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#getTargetClass - * () + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#getTargetClass() */ public ClassDefinition getTargetClass() { @@ -317,9 +300,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#getTargetRoleName - * () + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#getTargetRoleName() */ public QName getTargetRoleName() { @@ -335,9 +316,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#isSourceMandatory - * () + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isSourceMandatory() */ public boolean isSourceMandatory() { @@ -345,8 +324,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#isSourceMany() + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isSourceMany() */ public boolean isSourceMany() { @@ -354,9 +332,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMandatory - * () + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMandatory() */ public boolean isTargetMandatory() { @@ -364,8 +340,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @seeorg.alfresco.service.cmr.dictionary.AssociationDefinition# - * isTargetMandatoryEnforced() + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMandatoryEnforced() */ public boolean isTargetMandatoryEnforced() { @@ -373,8 +348,7 @@ public class MockClassAttributeDefinition implements PropertyDefinition, Associa } /* - * @see - * org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMany() + * @see org.alfresco.service.cmr.dictionary.AssociationDefinition#isTargetMany() */ public boolean isTargetMany() { diff --git a/source/java/org/alfresco/repo/forms/processor/node/MockFieldProcessorRegistry.java b/source/java/org/alfresco/repo/forms/processor/node/MockFieldProcessorRegistry.java index b49daa9f5d..3300cb99ce 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/MockFieldProcessorRegistry.java +++ b/source/java/org/alfresco/repo/forms/processor/node/MockFieldProcessorRegistry.java @@ -37,10 +37,10 @@ import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.namespace.NamespaceService; /** + * Mock implementation of a FieldProcessorRegistry. * * @since 3.4 * @author Nick Smith - * */ public class MockFieldProcessorRegistry extends ContentModelFieldProcessorRegistry { diff --git a/source/java/org/alfresco/repo/forms/processor/node/NodeFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/NodeFormProcessor.java index ce1566ad11..055d58a66f 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/NodeFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/NodeFormProcessor.java @@ -56,9 +56,7 @@ public class NodeFormProcessor extends ContentModelFormProcessor assocs) { Serializable value = assocs.get(name); - if(value == null) + if (value == null) { LinkedHashSet values = new LinkedHashSet(); values.add(target); @@ -180,7 +179,7 @@ public class NodeFormProcessor extends ContentModelFormProcessor) + if (value instanceof Set) { ((Set)value).add(target); } @@ -192,7 +191,7 @@ public class NodeFormProcessor extends ContentModelFormProcessor values = new HashMap(3); ContentData contentData = getContentData(item); - if(contentData!=null) + if (contentData != null) { values.put(EncodingFieldProcessor.KEY, contentData.getEncoding()); values.put(MimetypeFieldProcessor.KEY, contentData.getMimetype()); @@ -273,9 +272,7 @@ public class NodeFormProcessor extends ContentModelFormProcessor getDefaultIgnoredFields() - { - return null; - } } diff --git a/source/java/org/alfresco/repo/forms/processor/node/PropertyFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/PropertyFieldProcessor.java index aa12799cb5..b31b72c071 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/PropertyFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/PropertyFieldProcessor.java @@ -32,6 +32,7 @@ import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.FieldGroup; import org.alfresco.repo.forms.PropertyFieldDefinition; import org.alfresco.repo.forms.PropertyFieldDefinition.FieldConstraint; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.service.cmr.dictionary.Constraint; import org.alfresco.service.cmr.dictionary.ConstraintDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; @@ -46,10 +47,10 @@ import org.apache.commons.logging.LogFactory; import org.springframework.util.StringUtils; /** + * {@link FieldProcessor} implementation that handles properties. * * @since 3.4 * @author Nick Smith - * */ public class PropertyFieldProcessor extends QNameFieldProcessor { @@ -130,7 +131,7 @@ public class PropertyFieldProcessor extends QNameFieldProcessor data) { PropertyDefinition propDef = data.getPropertyDefinition(name); - if(propDef !=null) + if (propDef != null) { return propDef.getDefaultValue(); } diff --git a/source/java/org/alfresco/repo/forms/processor/node/QNameFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/QNameFieldProcessor.java index e74e339098..5f3cfd285a 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/QNameFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/QNameFieldProcessor.java @@ -24,6 +24,7 @@ import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.FieldDefinition; import org.alfresco.repo.forms.FieldGroup; import org.alfresco.repo.forms.processor.AbstractFieldProcessor; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.repo.forms.processor.FormCreationData; import org.alfresco.service.cmr.dictionary.ClassAttributeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; @@ -31,6 +32,7 @@ import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.QName; /** + * {@link FieldProcessor} implementation that handles QName fields. * * @since 3.4 * @author Nick Smith diff --git a/source/java/org/alfresco/repo/forms/processor/node/SizeFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/SizeFieldProcessor.java index 6b82c600e3..378c15b28d 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/SizeFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/SizeFieldProcessor.java @@ -23,22 +23,22 @@ import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DAT import org.alfresco.repo.forms.FieldDefinition; import org.alfresco.repo.forms.PropertyFieldDefinition; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; /** + * {@link FieldProcessor} implementation representing the size transient field. * * @since 3.4 * @author Nick Smith - * */ public class SizeFieldProcessor extends TransientFieldProcessor { private static final Log logger = LogFactory.getLog(SizeFieldProcessor.class); - public static final String KEY = "size"; private static final String MSG_SIZE_LABEL = "form_service.size.label"; diff --git a/source/java/org/alfresco/repo/forms/processor/node/TransientFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/TransientFieldProcessor.java index 36e822a2c1..d6ff4c3b3d 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/TransientFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/TransientFieldProcessor.java @@ -22,13 +22,14 @@ package org.alfresco.repo.forms.processor.node; import org.alfresco.repo.forms.Field; import org.alfresco.repo.forms.FieldDefinition; import org.alfresco.repo.forms.processor.AbstractFieldProcessor; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.repo.forms.processor.FormCreationData; /** + * Abstract base class for all transient {@link FieldProcessor}s. * * @since 3.4 * @author Nick Smith - * */ public abstract class TransientFieldProcessor extends AbstractFieldProcessor { diff --git a/source/java/org/alfresco/repo/forms/processor/node/TransientValueGetter.java b/source/java/org/alfresco/repo/forms/processor/node/TransientValueGetter.java index ed13efa8d5..5cab718511 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/TransientValueGetter.java +++ b/source/java/org/alfresco/repo/forms/processor/node/TransientValueGetter.java @@ -20,13 +20,12 @@ package org.alfresco.repo.forms.processor.node; /** + * Interface definition for an object that retrieves a transient filed value. * * @since 3.4 * @author Nick Smith - * */ public interface TransientValueGetter { - Object getTransientValue(String name); } diff --git a/source/java/org/alfresco/repo/forms/processor/node/TypeFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/node/TypeFormProcessor.java index cf88dc1a85..10a7dfaf39 100644 --- a/source/java/org/alfresco/repo/forms/processor/node/TypeFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/node/TypeFormProcessor.java @@ -19,9 +19,11 @@ package org.alfresco.repo.forms.processor.node; +import static org.alfresco.repo.forms.processor.node.FormFieldConstants.DATA_KEY_SEPARATOR; +import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP; + import java.io.Serializable; import java.util.HashMap; -import java.util.List; import java.util.Map; import org.alfresco.model.ContentModel; @@ -40,8 +42,6 @@ import org.alfresco.util.GUID; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import static org.alfresco.repo.forms.processor.node.FormFieldConstants.*; - /** * FormProcessor implementation that can generate and persist Form objects for * types in the Alfresco content model. @@ -57,15 +57,12 @@ public class TypeFormProcessor extends ContentModelFormProcessor getDefaultIgnoredFields() - { - return null; - } } diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/AbstractWorkflowFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/workflow/AbstractWorkflowFormProcessor.java index 2bf0877097..491cc2dcb1 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/AbstractWorkflowFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/AbstractWorkflowFormProcessor.java @@ -36,6 +36,7 @@ import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.util.ParameterCheck; /** + * Abstract base class for workflow based form processors. * * @since 3.4 * @author Nick Smith @@ -80,12 +81,9 @@ public abstract class AbstractWorkflowFormProcessor exten { this.workflowService = workflowService; } - /* - * @see - * org.alfresco.repo.forms.processor.node.NodeFormProcessor#getTypedItem - * (org.alfresco.repo.forms.Item) + * @see org.alfresco.repo.forms.processor.node.NodeFormProcessor#getTypedItem(org.alfresco.repo.forms.Item) */ @Override protected ItemType getTypedItem(Item item) @@ -111,7 +109,7 @@ public abstract class AbstractWorkflowFormProcessor exten private String decodeId(String itemId) { String decodedId = itemId; - if (itemId.contains("$")==false) + if (itemId.contains("$") == false) { decodedId = itemId.replaceFirst("_", Matcher.quoteReplacement("$")); } @@ -124,32 +122,40 @@ public abstract class AbstractWorkflowFormProcessor exten @Override protected List getDefaultIgnoredFields() { - ArrayList fields = new ArrayList(5); + List fields = super.getDefaultIgnoredFields(); + + if (fields == null) + { + fields = new ArrayList(20); + } + + // ignore document related properties fields.add("cm:name"); fields.add("cm:owner"); + fields.add("cm:creator"); + fields.add("cm:modifier"); + fields.add("cm:content"); + fields.add("cm:accessed"); + fields.add("cm:modified"); + fields.add("cm:created"); + + // ignore task properties that shouldn't be directly edited fields.add("bpm:package"); fields.add("bpm:pooledActors"); fields.add("bpm:completedItems"); - fields.add("sys:node-dbid"); - fields.add("sys:store-identifier"); fields.add("bpm:completionDate"); fields.add("bpm:context"); - fields.add("sys:node-uuid"); fields.add("bpm:hiddenTransitions"); fields.add("bpm:reassignable"); - fields.add("cm:creator"); - fields.add("cm:modifier"); + fields.add("bpm:startDate"); fields.add("bpm:packageActionGroup"); fields.add("bpm:packageItemActionGroup"); fields.add("bpm:outcome"); - fields.add("cm:content"); - fields.add("cm:accessed"); - fields.add("bpm:startDate"); - fields.add("cm:modified"); - fields.add("cm:created"); - fields.add("sys:store-protocol"); + fields.add("bpm:taskId"); + return fields; } + /** * Returns an implementation of {@link ContentModelFormPersister} which is * used to accumulate all the changes specified in the {@link Form} and then persist them. diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/ContentModelFormPersister.java b/source/java/org/alfresco/repo/forms/processor/workflow/ContentModelFormPersister.java index 2314d2b56a..45c92d51c7 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/ContentModelFormPersister.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/ContentModelFormPersister.java @@ -34,6 +34,7 @@ import org.apache.commons.logging.LogFactory; /** + * Utility class that assists in persisting content model related form data. * * @since 3.4 * @author Nick Smith @@ -75,7 +76,7 @@ public abstract class ContentModelFormPersister implements FormPersister else { boolean wasApplied = persistField(fieldData, keyInfo); - if(wasApplied == false) + if (wasApplied == false) { logIgnore(fieldData); } @@ -84,14 +85,14 @@ public abstract class ContentModelFormPersister implements FormPersister private boolean persistField(FieldData fieldData, DataKeyInfo keyInfo) { - switch(keyInfo.getFieldType()) + switch (keyInfo.getFieldType()) { - case PROPERTY: - return addProperty(keyInfo.getQName(), fieldData); - case TRANSIENT_PROPERTY: - return updateTransientProperty(keyInfo.getFieldName(), fieldData); - default: // Handle properties - return changeAssociation(keyInfo, fieldData); + case PROPERTY: + return addProperty(keyInfo.getQName(), fieldData); + case TRANSIENT_PROPERTY: + return updateTransientProperty(keyInfo.getFieldName(), fieldData); + default: // Handle properties + return changeAssociation(keyInfo, fieldData); } } @@ -102,7 +103,7 @@ public abstract class ContentModelFormPersister implements FormPersister protected boolean changeTransientAssociation(String fieldName, List values, boolean add) { - if(add) + if (add) { return addTransientAssociation(fieldName, values); } @@ -152,7 +153,7 @@ public abstract class ContentModelFormPersister implements FormPersister if (values.isEmpty()==false) { boolean add = info.isAdd(); - if(info.getFieldType() == FieldType.ASSOCIATION) + if (info.getFieldType() == FieldType.ASSOCIATION) { return changeAssociation(info.getQName(), values, add); } @@ -167,7 +168,7 @@ public abstract class ContentModelFormPersister implements FormPersister private boolean changeAssociation(QName qName, List values, boolean add) { - if(add) + if (add) { return addAssociation(qName, values); } @@ -179,7 +180,7 @@ public abstract class ContentModelFormPersister implements FormPersister protected void logIgnore(FieldData fieldData) { - if(logger.isDebugEnabled()) + if (logger.isDebugEnabled()) logger.debug("Ignoring unrecognized field: " + fieldData.getName()); } diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyInfo.java b/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyInfo.java index bc0098f7f0..64dc3ebd94 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyInfo.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyInfo.java @@ -22,10 +22,10 @@ package org.alfresco.repo.forms.processor.workflow; import org.alfresco.service.namespace.QName; /** + * Data transfer object that represents a data key. * * @since 3.4 * @author Nick Smith - * */ public class DataKeyInfo { diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyMatcher.java b/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyMatcher.java index 7933a99c06..cbe50cf904 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyMatcher.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/DataKeyMatcher.java @@ -28,10 +28,10 @@ import org.alfresco.service.namespace.QName; import static org.alfresco.repo.forms.processor.node.FormFieldConstants.*; /** + * Utility class used for matching data keys. * * @since 3.4 * @author Nick Smith - * */ public class DataKeyMatcher { @@ -71,7 +71,7 @@ public class DataKeyMatcher { return matchProperty(dataKey); } - else if(dataKey.startsWith(ASSOC_DATA_PREFIX)) + else if (dataKey.startsWith(ASSOC_DATA_PREFIX)) { return matchAssociation(dataKey); } @@ -96,7 +96,7 @@ public class DataKeyMatcher private DataKeyInfo matchTransientAssociation(String keyName) { Matcher matcher = transientAssociationPattern.matcher(keyName); - if(matcher.matches()) + if (matcher.matches()) { boolean isAdd = isAdd(matcher, 2); String name = matcher.group(1); diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/FieldType.java b/source/java/org/alfresco/repo/forms/processor/workflow/FieldType.java index 91c5fd22ab..7036be9960 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/FieldType.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/FieldType.java @@ -20,10 +20,10 @@ package org.alfresco.repo.forms.processor.workflow; /** + * Enum representing the various types of fields. * * @since 3.4 * @author Nick Smith - * */ public enum FieldType { diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/FormPersister.java b/source/java/org/alfresco/repo/forms/processor/workflow/FormPersister.java index b45c169787..3e922ac603 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/FormPersister.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/FormPersister.java @@ -22,6 +22,7 @@ package org.alfresco.repo.forms.processor.workflow; import org.alfresco.repo.forms.FormData.FieldData; /** + * Interface definition for a helper class that handles persisting form data. * * @since 3.4 * @author Nick Smith @@ -30,8 +31,6 @@ import org.alfresco.repo.forms.FormData.FieldData; */ public interface FormPersister { - - void addField(FieldData fieldData); T persist(); diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/TransitionFieldProcessor.java b/source/java/org/alfresco/repo/forms/processor/workflow/TransitionFieldProcessor.java index 06d75cac4a..fd24858620 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/TransitionFieldProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/TransitionFieldProcessor.java @@ -23,16 +23,17 @@ import static org.alfresco.repo.forms.processor.node.FormFieldConstants.PROP_DAT import org.alfresco.repo.forms.FieldDefinition; import org.alfresco.repo.forms.PropertyFieldDefinition; +import org.alfresco.repo.forms.processor.FieldProcessor; import org.alfresco.repo.forms.processor.node.TransientFieldProcessor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.extensions.surf.util.I18NUtil; /** + * {@link FieldProcessor} for handling the transitions of a workflow task. * * @since 3.4 * @author Nick Smith - * */ public class TransitionFieldProcessor extends TransientFieldProcessor { diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java b/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java index 24bdb35d1b..a98b3a2f74 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/TypedPropertyValueGetter.java @@ -38,10 +38,10 @@ import org.json.JSONException; import org.springframework.extensions.surf.util.I18NUtil; /** + * Utility class that retrieves the appropriately typed value for a property. * * @since 3.4 * @author Nick Smith - * */ public class TypedPropertyValueGetter { @@ -74,7 +74,7 @@ public class TypedPropertyValueGetter // make sure empty strings stay as empty strings, everything else // should be represented as null - if(valStr.length()==0 && !isTextProperty(propDef)) + if (valStr.length() == 0 && !isTextProperty(propDef)) { // Do nothing, leave typedValue as null. } diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormPersister.java b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormPersister.java index 5693832592..9a6787f04e 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormPersister.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormPersister.java @@ -35,10 +35,10 @@ import org.alfresco.service.namespace.QName; import org.apache.commons.logging.Log; /** + * Utility class that assists in persisting workflow related form data. * * @since 3.4 * @author Nick Smith - * */ public class WorkflowFormPersister extends ContentModelFormPersister { @@ -101,7 +101,7 @@ public class WorkflowFormPersister extends ContentModelFormPersister values) { - if(PackageItemsFieldProcessor.KEY.equals(fieldName)) + if (PackageItemsFieldProcessor.KEY.equals(fieldName)) { builder.addPackageItems(values); return true; diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java index 8ed20ef161..d622849c0c 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessor.java @@ -19,7 +19,9 @@ package org.alfresco.repo.forms.processor.workflow; import java.io.Serializable; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; import java.util.Map; import org.alfresco.repo.forms.processor.node.ContentModelItemData; @@ -35,7 +37,7 @@ import org.apache.commons.logging.LogFactory; * FormProcessor implementation that can generate and persist * Form objects for workflow definitions. * - *@since 3.4 + * @since 3.4 * @author Nick Smith */ public class WorkflowFormProcessor extends AbstractWorkflowFormProcessor @@ -58,7 +60,7 @@ public class WorkflowFormProcessor extends AbstractWorkflowFormProcessor itemData = makeItemData(item); return new WorkflowFormPersister(itemData, namespaceService, dictionaryService, workflowService, nodeService, logger); } + + /* + * @see org.alfresco.repo.forms.processor.workflow.AbstractWorkflowFormProcessor#getDefaultIgnoredFields() + */ + @Override + protected List getDefaultIgnoredFields() + { + List fields = super.getDefaultIgnoredFields(); + + if (fields == null) + { + fields = new ArrayList(3); + } + + // for the workflow form processor also hide the task specific + // description, due date and priority fields + fields.add("bpm:description"); + fields.add("bpm:dueDate"); + fields.add("bpm:priority"); + + return fields; + } } diff --git a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessorTest.java b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessorTest.java index 2559755a1f..733041dbd5 100644 --- a/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessorTest.java +++ b/source/java/org/alfresco/repo/forms/processor/workflow/WorkflowFormProcessorTest.java @@ -31,7 +31,7 @@ import static org.alfresco.repo.workflow.WorkflowModel.ASSOC_POOLED_ACTORS; import static org.alfresco.repo.workflow.WorkflowModel.PROP_DESCRIPTION; import static org.alfresco.repo.workflow.WorkflowModel.PROP_PACKAGE_ACTION_GROUP; import static org.alfresco.repo.workflow.WorkflowModel.PROP_PACKAGE_ITEM_ACTION_GROUP; -import static org.alfresco.repo.workflow.WorkflowModel.PROP_PRIORITY; +import static org.alfresco.repo.workflow.WorkflowModel.PROP_WORKFLOW_PRIORITY; import static org.alfresco.repo.workflow.WorkflowModel.PROP_STATUS; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyMap; @@ -61,6 +61,7 @@ import org.alfresco.repo.forms.FormData.FieldData; import org.alfresco.repo.forms.processor.node.DefaultFieldProcessor; import org.alfresco.repo.forms.processor.node.MockClassAttributeDefinition; import org.alfresco.repo.forms.processor.node.MockFieldProcessorRegistry; +import org.alfresco.repo.workflow.WorkflowModel; import org.alfresco.service.cmr.dictionary.AssociationDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DictionaryService; @@ -93,7 +94,7 @@ public class WorkflowFormProcessorTest extends TestCase { private static final String TASK_DEF_NAME = "TaskDef"; private static final String WF_DEF_NAME = "foo$wf:bar"; - private static final QName PRIORITY_NAME = PROP_PRIORITY; + private static final QName PRIORITY_NAME = PROP_WORKFLOW_PRIORITY; private static final QName DESC_NAME = PROP_DESCRIPTION; private static final QName STATUS_NAME = PROP_STATUS; private static final QName PROP_WITH_ = QName.createQName(NamespaceService.BPM_MODEL_1_0_URI, "some_prop"); @@ -207,7 +208,6 @@ public class WorkflowFormProcessorTest extends TestCase Form form = processForm(); List fieldDefs = form.getFieldDefinitionNames(); assertTrue(fieldDefs.contains(ASSIGNEE_NAME.toPrefixString(namespaceService))); - assertTrue(fieldDefs.contains(DESC_NAME.toPrefixString(namespaceService))); assertTrue(fieldDefs.contains(PRIORITY_NAME.toPrefixString(namespaceService))); assertTrue(fieldDefs.contains(PackageItemsFieldProcessor.KEY)); @@ -215,12 +215,16 @@ public class WorkflowFormProcessorTest extends TestCase assertFalse(fieldDefs.contains(ACTORS_NAME.toPrefixString(namespaceService))); assertFalse(fieldDefs.contains(PROP_PACKAGE_ACTION_GROUP.toPrefixString(namespaceService))); assertFalse(fieldDefs.contains(PROP_PACKAGE_ITEM_ACTION_GROUP.toPrefixString(namespaceService))); + assertFalse(fieldDefs.contains(WorkflowModel.PROP_DESCRIPTION.toPrefixString(namespaceService))); + assertFalse(fieldDefs.contains(WorkflowModel.PROP_DUE_DATE.toPrefixString(namespaceService))); + assertFalse(fieldDefs.contains(WorkflowModel.PROP_PRIORITY.toPrefixString(namespaceService))); + assertFalse(fieldDefs.contains(WorkflowModel.PROP_TASK_ID.toPrefixString(namespaceService))); Serializable fieldData = (Serializable) Collections.emptyList(); FormData formData = form.getFormData(); assertEquals(fieldData, formData.getFieldData("assoc_bpm_assignee").getValue()); checkPackageActionGroups(formData); - assertEquals("2", formData.getFieldData("prop_bpm_priority").getValue()); + assertEquals("2", formData.getFieldData("prop_bpm_workflowPriority").getValue()); } public void testGeneratePackageItems() throws Exception diff --git a/source/java/org/alfresco/repo/forms/script/test_formService.js b/source/java/org/alfresco/repo/forms/script/test_formService.js index 2fef098487..3b999e48e5 100644 --- a/source/java/org/alfresco/repo/forms/script/test_formService.js +++ b/source/java/org/alfresco/repo/forms/script/test_formService.js @@ -32,7 +32,7 @@ function testGetFormForContentNode() var fieldDefs = form.fieldDefinitions; test.assertNotNull(fieldDefs, "field definitions should not be null."); - test.assertEquals(22, fieldDefs.length); + test.assertEquals(18, fieldDefs.length); // as we know there are no duplicates we can safely create a map of the // field definitions for the purposes of this test @@ -154,7 +154,7 @@ function testGetFormForFolderNode() var fieldDefs = form.fieldDefinitions; test.assertNotNull(fieldDefs, "field definitions should not be null."); - test.assertEquals(11, fieldDefs.length); + test.assertEquals(7, fieldDefs.length); // as we know there are no duplicates we can safely create a map of the // field definitions for the purposes of this test diff --git a/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java b/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java index be47858c5c..1ad0fc0d72 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowBuilder.java @@ -65,7 +65,7 @@ public class WorkflowBuilder public void addAssociationParameter(QName name, List values) { - if(values instanceof Serializable) + if (values instanceof Serializable) { params.put(name, (Serializable) values); } @@ -96,13 +96,15 @@ public class WorkflowBuilder private void signalStartTask(WorkflowPath path) { List tasks = workflowService.getTasksForWorkflowPath(path.getId()); - if(tasks.size() == 1) + if (tasks.size() == 1) { WorkflowTask startTask = tasks.get(0); workflowService.endTask(startTask.id, null); } else + { throw new WorkflowException("Start task not found! Expected 1 task but found: " + tasks.size()); + } } }