Class ContentModelFormProcessor<ItemType,PersistType>
- java.lang.Object
-
- org.alfresco.repo.forms.processor.AbstractFormProcessor
-
- org.alfresco.repo.forms.processor.FilteredFormProcessor<ItemType,PersistType>
-
- org.alfresco.repo.forms.processor.node.ContentModelFormProcessor<ItemType,PersistType>
-
- All Implemented Interfaces:
FormProcessor
- Direct Known Subclasses:
AbstractWorkflowFormProcessor,NodeFormProcessor,TypeFormProcessor
public abstract class ContentModelFormProcessor<ItemType,PersistType> extends FilteredFormProcessor<ItemType,PersistType>
Abstract FormProcessor implementation that provides common functionality for form processors that deal with Alfresco content models i.e. types and nodes.- Author:
- Gavin Cornwell, Nick Smith
-
-
Field Summary
Fields Modifier and Type Field Description protected PatternassociationNamePatternA regular expression which can be used to match association names.protected ContentServicecontentServiceprotected DictionaryServicedictionaryServiceprotected FileFolderServicefileFolderServiceprotected NamespaceServicenamespaceServiceprotected NodeServicenodeServiceServicesprotected PermissionServicepermissionServiceprotected PatternpropertyNamePatternA regular expression which can be used to match property names.protected PatterntransientPropertyPatternA 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
Constructors Constructor Description ContentModelFormProcessor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddPropertyDataIfRequired(QName propName, Form form, ContentModelItemData<?> itemData)protected StringdetermineDefaultMimetype(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 returnedprotected List<Field>generateDefaultFields(FormCreationData data, List<String> fieldsToIgnore)Generates a list of default fields to add if no field names are specified.protected Set<QName>getAspectNames(ItemType item)protected abstract Map<QName,Serializable>getAssociationValues(ItemType item)protected abstract TypeDefinitiongetBaseType(ItemType item)protected List<String>getDefaultIgnoredFields()protected abstract Map<QName,Serializable>getPropertyValues(ItemType item)protected abstract Map<String,Object>getTransientValues(ItemType item)protected ContentModelItemData<ItemType>makeItemData(ItemType item)protected voidpersistNode(NodeRef nodeRef, FormData data)Persists the given FormData on the given NodeRefprotected voidprocessAssociationPersist(NodeRef nodeRef, Map<QName,AssociationDefinition> assocDefs, Map<QName,ChildAssociationDefinition> childAssocDefs, FormData.FieldData fieldData, List<org.alfresco.repo.forms.processor.node.AbstractAssocCommand> assocCommands)Processes the given field data for persistence as an association.protected voidprocessContentPropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist, FormData data)Persists the given field data as the contentprotected voidprocessEncodingPropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist)Persists the given field data as the encoding propertyprotected voidprocessMimetypePropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist)Persists the given field data as the mimetype propertyprotected voidprocessNamePropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist)Persists the given field data as the name propertyprotected voidprocessPropertyPersist(NodeRef nodeRef, Map<QName,PropertyDefinition> propDefs, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist, FormData data)Processes the given field data for persistence as a property.voidsetContentService(ContentService contentService)Sets the content servicevoidsetDictionaryService(DictionaryService dictionaryService)Sets the data dictionary servicevoidsetFileFolderService(FileFolderService fileFolderService)Sets the file folder servicevoidsetNamespaceService(NamespaceService namespaceService)Sets the namespace servicevoidsetNodeService(NodeService nodeService)Sets the node servicevoidsetPermissionService(PermissionService permissionService)Sets the content 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
-
-
-
-
Field Detail
-
nodeService
protected NodeService nodeService
Services
-
fileFolderService
protected FileFolderService fileFolderService
-
dictionaryService
protected DictionaryService dictionaryService
-
namespaceService
protected NamespaceService namespaceService
-
contentService
protected ContentService contentService
-
permissionService
protected PermissionService permissionService
-
propertyNamePattern
protected 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 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 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.
-
-
Method Detail
-
setNodeService
public void setNodeService(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(DictionaryService dictionaryService)
Sets the data dictionary service- Parameters:
dictionaryService- The DictionaryService instance
-
setNamespaceService
public void setNamespaceService(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
-
setPermissionService
public void setPermissionService(PermissionService permissionService)
Sets the content service- Parameters:
permissionService- The PermissionService instance
-
addPropertyDataIfRequired
protected void addPropertyDataIfRequired(QName propName, Form form, ContentModelItemData<?> itemData)
-
generateDefaultFields
protected List<Field> generateDefaultFields(FormCreationData data, List<String> fieldsToIgnore)
Description copied from class:FilteredFormProcessorGenerates a list of default fields to add if no field names are specified.- Overrides:
generateDefaultFieldsin classFilteredFormProcessor<ItemType,PersistType>- Parameters:
data- Used for field creation.fieldsToIgnore- TODO- Returns:
- a
ListofFieldswhich may be empty.
-
makeItemData
protected ContentModelItemData<ItemType> makeItemData(ItemType item)
Description copied from class:FilteredFormProcessor- Specified by:
makeItemDatain classFilteredFormProcessor<ItemType,PersistType>- Returns:
- Object
-
getDefaultIgnoredFields
protected List<String> getDefaultIgnoredFields()
Description copied from class:FilteredFormProcessorWhen aFormis generated with no field names specifically set then a defaultFormis created. The defaultFormcontains all the properties and associations related to theItem, 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 propertyignoredFields.- Specified by:
getDefaultIgnoredFieldsin classFilteredFormProcessor<ItemType,PersistType>- Returns:
- the names of all the fields to be excluded from the default
Formif nodefaultFieldsproperty is explicitly set.
-
getAssociationValues
protected abstract Map<QName,Serializable> getAssociationValues(ItemType item)
-
getPropertyValues
protected abstract Map<QName,Serializable> getPropertyValues(ItemType item)
-
getBaseType
protected abstract TypeDefinition getBaseType(ItemType item)
-
persistNode
protected void persistNode(NodeRef nodeRef, FormData data)
Persists the given FormData on the given NodeRef- Parameters:
nodeRef- The NodeRef to persist the form data ondata- The FormData to persist
-
processPropertyPersist
protected void processPropertyPersist(NodeRef nodeRef, Map<QName,PropertyDefinition> propDefs, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist, FormData data)
Processes the given field data for persistence as a property.- Parameters:
nodeRef- The NodeRef to persist the properties onpropDefs- Map of PropertyDefinition's for the node being persistedfieldData- Data to persist for the propertypropsToPersist- Map of properties to be persisteddata- The FormData to persist
-
processAssociationPersist
protected void processAssociationPersist(NodeRef nodeRef, Map<QName,AssociationDefinition> assocDefs, Map<QName,ChildAssociationDefinition> childAssocDefs, FormData.FieldData fieldData, List<org.alfresco.repo.forms.processor.node.AbstractAssocCommand> assocCommands)
Processes the given field data for persistence as an association.- Parameters:
nodeRef- The NodeRef to persist the associations onfieldData- Data to persist for the associationsassocCommands- List of associations to be persisted
-
processNamePropertyPersist
protected void processNamePropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist)
Persists the given field data as the name property- Parameters:
nodeRef- The NodeRef to update the name forfieldData- The data representing the new name valuepropsToPersist- Map of properties to be persisted
-
processMimetypePropertyPersist
protected void processMimetypePropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist)
Persists the given field data as the mimetype property- Parameters:
nodeRef- The NodeRef to update the mimetype forfieldData- The data representing the new mimetype valuepropsToPersist- Map of properties to be persisted
-
processEncodingPropertyPersist
protected void processEncodingPropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist)
Persists the given field data as the encoding property- Parameters:
nodeRef- The NodeRef to update the encoding forfieldData- The data representing the new encoding valuepropsToPersist- Map of properties to be persisted
-
processContentPropertyPersist
protected void processContentPropertyPersist(NodeRef nodeRef, FormData.FieldData fieldData, Map<QName,Serializable> propsToPersist, FormData data)
Persists the given field data as the content- Parameters:
nodeRef- The NodeRef to update the content forfieldData- The data representing the new contentpropsToPersist- Map of properties to be persisteddata- The form data being persisted
-
determineDefaultMimetype
protected 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
-
-