You are here

Retrieving Process Definitions

You learn how to retrieve a list of process definitions.
You need to have a clean version of HelloRepo that compiles and runs. You can see this tutorial for instructions on how to do that.
This tutorial shows you how to use the workflow API to retrieve a list of workflow process definitions.
  1. Add the following method after loadRootFolder in the HelloRepo code:

              
    - (void) createWorkflow
    {
        NSLog(@"*********** createWorkflow");
        
        // create service
        SkyVaultWorkflowService *workflowService = [[AlfrescoWorkflowService alloc] initWithSession:self.session];
        
        // list process definitions available
        
        [workflowService retrieveProcessDefinitionsWithCompletionBlock:^(NSArray *array, NSError *error) {
            
            if (array == nil)
            {
                NSLog(@"Failed to retrieve process definitions: %@", error);
            }
            
            
            // for each item in the array print out some information
            for (AlfrescoWorkflowProcessDefinition *pd in array)
            {
                NSLog(@"---> Identifier: %@\n", pd.identifier);
                NSLog(@"---> Key: %@\n", pd.key);
                NSLog(@"---> Name: %@\n", pd.name);
                NSLog(@"---> Summary: %@\n", pd.summary);
                NSLog(@"---> Version: %@\n", pd.version);
            }
            
        }];
    }
    
            
  2. After the call to loadRootFolder add a call to the createWorkflow method and comment out the call to the loadRootFolder method, so the modified code looks like the following:

                
      ...          
      NSLog(@"Authenticated successfully");
      NSLog(@"Repository version: %@", session.repositoryInfo.version);
      NSLog(@"Repository edition: %@", session.repositoryInfo.edition);
      weakSelf.session = session;
      // [weakSelf loadRootFolder];
      [weakSelf createWorkflow];
      ...          
                
              
  3. Build and run your code.
  4. Examine the log messages in the Xcode output window. You will see a list of process definitions:

                
    2014-04-24 09:30:41.601 HelloRepo[10364:60b] *********** helloFromRepository
    2014-04-24 09:30:41.760 HelloRepo[10364:60b] Authenticated successfully
    2014-04-24 09:30:41.760 HelloRepo[10364:60b] Repository version: 4.2.1 (r63452-b50)
    2014-04-24 09:30:41.761 HelloRepo[10364:60b] Repository edition: Enterprise
    2014-04-24 09:30:41.761 HelloRepo[10364:60b] *********** createWorkflow
    2014-04-24 09:30:41.777 HelloRepo[10364:60b] ---> Identifier: activitiAdhoc:1:4
    2014-04-24 09:30:41.777 HelloRepo[10364:60b] ---> Key: activitiAdhoc
    2014-04-24 09:30:41.777 HelloRepo[10364:60b] ---> Name: New Task
    2014-04-24 09:30:41.777 HelloRepo[10364:60b] ---> Summary: Assign a new task to yourself or a colleague
    2014-04-24 09:30:41.778 HelloRepo[10364:60b] ---> Version: 1
    2014-04-24 09:30:41.778 HelloRepo[10364:60b] ---> Identifier: activitiParallelGroupReview:1:20
    2014-04-24 09:30:41.778 HelloRepo[10364:60b] ---> Key: activitiParallelGroupReview
    2014-04-24 09:30:41.778 HelloRepo[10364:60b] ---> Name: Group Review And Approve
    2014-04-24 09:30:41.779 HelloRepo[10364:60b] ---> Summary: Group review and approval of content using Activiti workflow engine
    2014-04-24 09:30:41.779 HelloRepo[10364:60b] ---> Version: 1
    2014-04-24 09:30:41.779 HelloRepo[10364:60b] ---> Identifier: activitiParallelReview:1:16
    2014-04-24 09:30:41.780 HelloRepo[10364:60b] ---> Key: activitiParallelReview
    2014-04-24 09:30:41.780 HelloRepo[10364:60b] ---> Name: Send Document(s) For Review
    2014-04-24 09:30:41.780 HelloRepo[10364:60b] ---> Summary: Request document approval from one or more colleagues
    2014-04-24 09:30:41.780 HelloRepo[10364:60b] ---> Version: 1
    2014-04-24 09:30:41.781 HelloRepo[10364:60b] ---> Identifier: activitiReview:1:8
    2014-04-24 09:30:41.781 HelloRepo[10364:60b] ---> Key: activitiReview
    2014-04-24 09:30:41.781 HelloRepo[10364:60b] ---> Name: Review And Approve
    2014-04-24 09:30:41.781 HelloRepo[10364:60b] ---> Summary: Review and approval of content using Activiti workflow engine
    2014-04-24 09:30:41.782 HelloRepo[10364:60b] ---> Version: 1
    2014-04-24 09:30:41.782 HelloRepo[10364:60b] ---> Identifier: activitiReviewPooled:1:12
    2014-04-24 09:30:41.782 HelloRepo[10364:60b] ---> Key: activitiReviewPooled
    2014-04-24 09:30:41.782 HelloRepo[10364:60b] ---> Name: Pooled Review And Approve
    2014-04-24 09:30:41.783 HelloRepo[10364:60b] ---> Summary: Pooled review and approval of content using Activiti workflow engine
    2014-04-24 09:30:41.783 HelloRepo[10364:60b] ---> Version: 1
                
              

    Your results may vary depending on the version of SkyVault you are using.