org.alfresco.repo.forms.processor.node
Class ContentModelFormProcessor

java.lang.Object
  extended by org.alfresco.repo.forms.processor.AbstractFormProcessor
      extended by org.alfresco.repo.forms.processor.FilteredFormProcessor
          extended by org.alfresco.repo.forms.processor.node.ContentModelFormProcessor
All Implemented Interfaces:
FormProcessor
Direct Known Subclasses:
AbstractWorkflowFormProcessor, NodeFormProcessor, TypeFormProcessor

public abstract class ContentModelFormProcessor
extends FilteredFormProcessor

Abstract FormProcessor implementation that provides common functionality for form processors that deal with Alfresco content models i.e. types and nodes.


Field Summary
protected  java.util.regex.Pattern associationNamePattern
          A regular expression which can be used to match association names.
protected  ContentService contentService
           
protected  org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService
           
protected  FileFolderService fileFolderService
           
protected  org.alfresco.service.namespace.NamespaceService namespaceService
           
protected  org.alfresco.service.cmr.repository.NodeService nodeService
          Services
protected  java.util.regex.Pattern propertyNamePattern
          A regular expression which can be used to match property names.
protected  java.util.regex.Pattern transientPropertyPattern
          A regular expression which can be used to match tranisent property names.
 
Fields inherited from class org.alfresco.repo.forms.processor.FilteredFormProcessor
fieldProcessorRegistry, filterRegistry
 
Fields inherited from class org.alfresco.repo.forms.processor.AbstractFormProcessor
active, DESTINATION, matchPattern, patternMatcher, processorRegistry
 
Constructor Summary
ContentModelFormProcessor()
           
 
Method Summary
protected  void addPropertyDataIfRequired(org.alfresco.service.namespace.QName propName, Form form, ContentModelItemData itemData)
           
protected  java.lang.String determineDefaultMimetype(FormData data)
          Looks through the form data for the 'mimetype' transient field and returns it's value if found, otherwise the default 'text/plain' is returned
protected  java.util.List generateDefaultFields(FormCreationData data, java.util.List fieldsToIgnore)
          Generates a list of default fields to add if no field names are specified.
protected  java.util.Set getAspectNames(java.lang.Object item)
           
protected abstract  java.util.Map getAssociationValues(java.lang.Object item)
           
protected abstract  org.alfresco.service.cmr.dictionary.TypeDefinition getBaseType(java.lang.Object item)
           
protected  java.util.List getDefaultIgnoredFields()
          When a Form is generated with no field names specifically set then a default Form is created.
protected abstract  java.util.Map getPropertyValues(java.lang.Object item)
           
protected abstract  java.util.Map getTransientValues(java.lang.Object item)
           
protected  ContentModelItemData makeItemData(java.lang.Object item)
          Creates a data object used by the FormProcessor and FieldProcessors to create Fields
protected  void persistNode(org.alfresco.service.cmr.repository.NodeRef nodeRef, FormData data)
          Persists the given FormData on the given NodeRef
protected  void processAssociationPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.Map assocDefs, java.util.Map childAssocDefs, FormData.FieldData fieldData, java.util.List assocCommands)
          Processes the given field data for persistence as an association.
protected  void processContentPropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef, FormData.FieldData fieldData, java.util.Map propsToPersist, FormData data)
          Persists the given field data as the content
protected  void processEncodingPropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef, FormData.FieldData fieldData, java.util.Map propsToPersist)
          Persists the given field data as the encoding property
protected  void processMimetypePropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef, FormData.FieldData fieldData, java.util.Map propsToPersist)
          Persists the given field data as the mimetype property
protected  void processNamePropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef, FormData.FieldData fieldData, java.util.Map propsToPersist)
          Persists the given field data as the name property
protected  void processPropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.util.Map propDefs, FormData.FieldData fieldData, java.util.Map propsToPersist, FormData data)
          Processes the given field data for persistence as a property.
 void setContentService(ContentService contentService)
          Sets the content service
 void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
          Sets the data dictionary service
 void setFileFolderService(FileFolderService fileFolderService)
          Sets the file folder service
 void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
          Sets the namespace service
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
          Sets the node service
 
Methods inherited from class org.alfresco.repo.forms.processor.FilteredFormProcessor
generate, generateSelectedFields, getItemType, getItemURI, getLogger, getTypedItem, internalGenerate, internalPersist, persist, populateForm, setFieldProcessorRegistry, setFilterRegistry, setIgnoredFields
 
Methods inherited from class org.alfresco.repo.forms.processor.AbstractFormProcessor
isActive, isApplicable, register, setActive, setFormItemType, setFormItemUrl, setMatchPattern, setProcessorRegistry, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nodeService

protected org.alfresco.service.cmr.repository.NodeService nodeService
Services


fileFolderService

protected FileFolderService fileFolderService

dictionaryService

protected org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService

namespaceService

protected org.alfresco.service.namespace.NamespaceService namespaceService

contentService

protected ContentService contentService

propertyNamePattern

protected java.util.regex.Pattern propertyNamePattern
A regular expression which can be used to match property names. These names will look like "prop_cm_name". The pattern can also be used to extract the "cm" and the "name" parts.


transientPropertyPattern

protected java.util.regex.Pattern transientPropertyPattern
A regular expression which can be used to match tranisent property names. These names will look like "prop_name". The pattern can also be used to extract the "name" part.


associationNamePattern

protected java.util.regex.Pattern associationNamePattern
A regular expression which can be used to match association names. These names will look like "assoc_cm_references_added". The pattern can also be used to extract the "cm", the "name" and the suffix parts.

Constructor Detail

ContentModelFormProcessor

public ContentModelFormProcessor()
Method Detail

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
Sets the node service

Parameters:
nodeService - The NodeService instance

setFileFolderService

public void setFileFolderService(FileFolderService fileFolderService)
Sets the file folder service

Parameters:
fileFolderService - The FileFolderService instance

setDictionaryService

public void setDictionaryService(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
Sets the data dictionary service

Parameters:
dictionaryService - The DictionaryService instance

setNamespaceService

public void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
Sets the namespace service

Parameters:
namespaceService - The NamespaceService instance

setContentService

public void setContentService(ContentService contentService)
Sets the content service

Parameters:
contentService - The ContentService instance

addPropertyDataIfRequired

protected void addPropertyDataIfRequired(org.alfresco.service.namespace.QName propName,
                                         Form form,
                                         ContentModelItemData itemData)

generateDefaultFields

protected java.util.List generateDefaultFields(FormCreationData data,
                                               java.util.List fieldsToIgnore)
Description copied from class: FilteredFormProcessor
Generates a list of default fields to add if no field names are specified.

Overrides:
generateDefaultFields in class FilteredFormProcessor
Parameters:
data - Used for field creation.
Returns:
a List of Fields which may be empty.

makeItemData

protected ContentModelItemData makeItemData(java.lang.Object item)
Description copied from class: FilteredFormProcessor
Creates a data object used by the FormProcessor and FieldProcessors to create Fields

Specified by:
makeItemData in class FilteredFormProcessor
Returns:

getDefaultIgnoredFields

protected java.util.List getDefaultIgnoredFields()
Description copied from class: FilteredFormProcessor
When a Form is generated with no field names specifically set then a default Form is created. The default Form contains all the properties and associations related to the Item, excluding a blacklist of ignored fields which defaults to the return value of this method. The default ignored values can be overridden by setting the property ignoredFields.

Specified by:
getDefaultIgnoredFields in class FilteredFormProcessor
Returns:
the names of all the fields to be excluded from the default Form if no defaultFields property is explicitly set.

getAspectNames

protected java.util.Set getAspectNames(java.lang.Object item)

getAssociationValues

protected abstract java.util.Map getAssociationValues(java.lang.Object item)

getPropertyValues

protected abstract java.util.Map getPropertyValues(java.lang.Object item)

getTransientValues

protected abstract java.util.Map getTransientValues(java.lang.Object item)

getBaseType

protected abstract org.alfresco.service.cmr.dictionary.TypeDefinition getBaseType(java.lang.Object item)

persistNode

protected void persistNode(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                           FormData data)
Persists the given FormData on the given NodeRef

Parameters:
nodeRef - The NodeRef to persist the form data on
data - The FormData to persist

processPropertyPersist

protected void processPropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                      java.util.Map propDefs,
                                      FormData.FieldData fieldData,
                                      java.util.Map propsToPersist,
                                      FormData data)
Processes the given field data for persistence as a property.

Parameters:
nodeRef - The NodeRef to persist the properties on
propDefs - Map of PropertyDefinition's for the node being persisted
fieldData - Data to persist for the property
propsToPersist - Map of properties to be persisted
data - The FormData to persist

processAssociationPersist

protected void processAssociationPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                         java.util.Map assocDefs,
                                         java.util.Map childAssocDefs,
                                         FormData.FieldData fieldData,
                                         java.util.List assocCommands)
Processes the given field data for persistence as an association.

Parameters:
nodeRef - The NodeRef to persist the associations on
fieldData - Data to persist for the associations
assocCommands - List of associations to be persisted

processNamePropertyPersist

protected void processNamePropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                          FormData.FieldData fieldData,
                                          java.util.Map propsToPersist)
Persists the given field data as the name property

Parameters:
nodeRef - The NodeRef to update the name for
fieldData - The data representing the new name value
propsToPersist - Map of properties to be persisted

processMimetypePropertyPersist

protected void processMimetypePropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                              FormData.FieldData fieldData,
                                              java.util.Map propsToPersist)
Persists the given field data as the mimetype property

Parameters:
nodeRef - The NodeRef to update the mimetype for
fieldData - The data representing the new mimetype value
propsToPersist - Map of properties to be persisted

processEncodingPropertyPersist

protected void processEncodingPropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                              FormData.FieldData fieldData,
                                              java.util.Map propsToPersist)
Persists the given field data as the encoding property

Parameters:
nodeRef - The NodeRef to update the encoding for
fieldData - The data representing the new encoding value
propsToPersist - Map of properties to be persisted

processContentPropertyPersist

protected void processContentPropertyPersist(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                             FormData.FieldData fieldData,
                                             java.util.Map propsToPersist,
                                             FormData data)
Persists the given field data as the content

Parameters:
nodeRef - The NodeRef to update the content for
fieldData - The data representing the new content
propsToPersist - Map of properties to be persisted
data - The form data being persisted

determineDefaultMimetype

protected java.lang.String determineDefaultMimetype(FormData data)
Looks through the form data for the 'mimetype' transient field and returns it's value if found, otherwise the default 'text/plain' is returned

Parameters:
data - Form data being persisted
Returns:
The default mimetype


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.