Class RestVariableHelper


  • public class RestVariableHelper
    extends java.lang.Object
    Helper class for handling conversion between variable representations in rest and raw values used in the Activiti-engine.
    Author:
    Frederik Heremans
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Set<java.lang.String> INTERNAL_PROPERTIES  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTaskVariables​(java.util.List<TaskVariable> result, java.util.Map<java.lang.String,​java.lang.Object> variables, TypeDefinitionContext context, VariableScope scope)
      Converts the raw variables to TaskVariables and adds them to the given result-list.
      org.alfresco.service.namespace.QName extractTypeFromValue​(java.lang.Object value)  
      java.lang.String extractTypeStringFromValue​(java.lang.Object value)  
      protected java.lang.Object getAssociationRepresentation​(java.lang.Object value, org.alfresco.service.cmr.dictionary.AssociationDefinition assocDef)  
      protected org.alfresco.repo.workflow.WorkflowQNameConverter getQNameConverter()  
      protected java.lang.String getRepresentationForNodeRef​(java.lang.Object value, org.alfresco.service.cmr.dictionary.ClassDefinition classDefinition)  
      protected java.lang.Object getSafePropertyValue​(java.lang.Object value)  
      java.util.List<TaskVariable> getTaskVariables​(java.util.Map<java.lang.String,​java.lang.Object> localVariables, java.util.Map<java.lang.String,​java.lang.Object> globalVariables, org.alfresco.service.cmr.dictionary.TypeDefinition startFormTypeDefinition, org.alfresco.service.cmr.dictionary.TypeDefinition taskTypeDefinition)  
      java.util.List<Variable> getVariables​(java.util.Map<java.lang.String,​java.lang.Object> variables, org.alfresco.service.cmr.dictionary.TypeDefinition typeDefinition)  
      void setDictionaryService​(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)  
      void setNamespaceService​(org.alfresco.service.namespace.NamespaceService namespaceService)  
      void setNodeService​(org.alfresco.service.cmr.repository.NodeService nodeService)  
      protected void setVariableValueAndType​(Variable variable, java.lang.Object value, TypeDefinitionContext context)
      Sets the variable value with possible conversion to the correct format to be used in the response and sets the type accordingly.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INTERNAL_PROPERTIES

        public static final java.util.Set<java.lang.String> INTERNAL_PROPERTIES
    • Constructor Detail

      • RestVariableHelper

        public RestVariableHelper()
    • Method Detail

      • setNodeService

        public void setNodeService​(org.alfresco.service.cmr.repository.NodeService nodeService)
      • setNamespaceService

        public void setNamespaceService​(org.alfresco.service.namespace.NamespaceService namespaceService)
      • setDictionaryService

        public void setDictionaryService​(org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService)
      • getQNameConverter

        protected org.alfresco.repo.workflow.WorkflowQNameConverter getQNameConverter()
      • getTaskVariables

        public java.util.List<TaskVariable> getTaskVariables​(java.util.Map<java.lang.String,​java.lang.Object> localVariables,
                                                             java.util.Map<java.lang.String,​java.lang.Object> globalVariables,
                                                             org.alfresco.service.cmr.dictionary.TypeDefinition startFormTypeDefinition,
                                                             org.alfresco.service.cmr.dictionary.TypeDefinition taskTypeDefinition)
        Parameters:
        localVariables - raw local task variables, can be null.
        globalVariables - raw global taks variables, can be null.
        startFormTypeDefinition - TypeDefinition
        taskTypeDefinition - the typê definition for this task, used to extract types.
        Returns:
        list of TaskVariable, representing the given raw variables
      • getVariables

        public java.util.List<Variable> getVariables​(java.util.Map<java.lang.String,​java.lang.Object> variables,
                                                     org.alfresco.service.cmr.dictionary.TypeDefinition typeDefinition)
        Parameters:
        variables - raw variables
        typeDefinition - the typê definition for the start-task of the process, used to extract types.
        Returns:
        list of Variable, representing the given raw variables
      • addTaskVariables

        public void addTaskVariables​(java.util.List<TaskVariable> result,
                                     java.util.Map<java.lang.String,​java.lang.Object> variables,
                                     TypeDefinitionContext context,
                                     VariableScope scope)
        Converts the raw variables to TaskVariables and adds them to the given result-list.
      • setVariableValueAndType

        protected void setVariableValueAndType​(Variable variable,
                                               java.lang.Object value,
                                               TypeDefinitionContext context)
        Sets the variable value with possible conversion to the correct format to be used in the response and sets the type accordingly. If the variables is defined on the TypeDefinition, the data-type is used. If it's not defined, the type is deducted from the raw variable value.
      • getAssociationRepresentation

        protected java.lang.Object getAssociationRepresentation​(java.lang.Object value,
                                                                org.alfresco.service.cmr.dictionary.AssociationDefinition assocDef)
        Returns:
        object that represents the association value.
      • getSafePropertyValue

        protected java.lang.Object getSafePropertyValue​(java.lang.Object value)
      • getRepresentationForNodeRef

        protected java.lang.String getRepresentationForNodeRef​(java.lang.Object value,
                                                               org.alfresco.service.cmr.dictionary.ClassDefinition classDefinition)
      • extractTypeFromValue

        public org.alfresco.service.namespace.QName extractTypeFromValue​(java.lang.Object value)
      • extractTypeStringFromValue

        public java.lang.String extractTypeStringFromValue​(java.lang.Object value)