github.com/TIBCOSoftware/flogo-lib@v0.5.9/core/activity/context.go (about)

     1  package activity
     2  
     3  import (
     4  	"github.com/TIBCOSoftware/flogo-lib/core/data"
     5  	)
     6  
     7  // Context describes the execution context for an Activity.
     8  // It provides access to attributes, task and Flow information.
     9  type Context interface {
    10  
    11  	// ActivityHost gets the "host" under with the activity is executing
    12  	ActivityHost() Host
    13  
    14  	//Name the name of the activity that is currently executing
    15  	Name() string
    16  
    17  	// GetInput gets the value of the specified input attribute
    18  	GetInput(name string) interface{}
    19  
    20  	// GetOutput gets the value of the specified output attribute
    21  	GetOutput(name string) interface{}
    22  
    23  	// SetOutput sets the value of the specified output attribute
    24  	SetOutput(name string, value interface{})
    25  
    26  	//// GetSharedTempData get shared temporary data for activity, lifespan
    27  	//// of the data dependent on the activity host implementation
    28  	//GetSharedTempData() map[string]interface{}
    29  
    30  	/////////////////
    31  	// Deprecated
    32  
    33  	// GetSetting gets the value of the specified setting
    34  	// Deprecated
    35  	GetSetting(setting string) (value interface{}, exists bool)
    36  
    37  	// GetInitValue gets the specified initialization value
    38  	// Deprecated
    39  	GetInitValue(key string) (value interface{}, exists bool)
    40  
    41  	// Deprecated: Use ActivityHost().Name() instead.
    42  	TaskName() string
    43  
    44  	// Deprecated: Use ActivityHost() instead.
    45  	FlowDetails() FlowDetails
    46  
    47  	/////////////////
    48  }
    49  
    50  type Host interface {
    51  
    52  	// ID returns the ID of the Activity Host
    53  	ID() string
    54  
    55  	// Name the name of the Activity Host
    56  	Name() string
    57  
    58  	// IOMetadata get the input/output metadata of the activity host
    59  	IOMetadata() *data.IOMetadata
    60  
    61  	// Reply is used to reply to the activity Host with the results of the execution
    62  	Reply(replyData map[string]*data.Attribute, err error)
    63  
    64  	// Return is used to indicate to the activity Host that it should complete and return the results of the execution
    65  	Return(returnData map[string]*data.Attribute, err error)
    66  
    67  	//todo rename, essentially the flow's attrs for now
    68  	WorkingData() data.Scope
    69  
    70  	// GetResolver gets the resolver associated with the activity host
    71  	GetResolver() data.Resolver
    72  
    73  	//Map with action specific details/properties, flowId, etc.
    74  	//GetDetails() map[string]string
    75  }
    76  
    77  
    78  // Deprecated: Use ActivityHost() instead.
    79  type FlowDetails interface {
    80  
    81  	// ID returns the ID of the Flow Instance
    82  	ID() string
    83  
    84  	// FlowName returns the name of the Flow
    85  	Name() string
    86  
    87  	// ReplyHandler returns the reply handler for the flow Instance
    88  	ReplyHandler() ReplyHandler
    89  }
    90  
    91  //SharedTempDataSupport - temporary interface until we transition this to activity.Context
    92  //Deprecated
    93  type SharedTempDataSupport interface {
    94  
    95  	// GetSharedTempData get shared temporary data for activity, lifespan
    96  	// of the data dependent on the activity host implementation
    97  	GetSharedTempData() map[string]interface{}
    98  }
    99  
   100  // GetSharedTempDataSupport for the activity
   101  func GetSharedTempDataSupport(ctx Context) (SharedTempDataSupport, bool) {
   102  
   103  	ts, ok :=  ctx.(SharedTempDataSupport)
   104  	return ts, ok
   105  }