Generic Process Flows

You may recall that when discussing Business Logic Metadata we had a process flow that executed an explicit stored procedure.  This doesn't mean you have to create a process flow for every single stored procedure you want to execute through services.  Aptify has developed several generic process flows for performing common operations through the services layer.  Some examples are:

All process flows are assigned to the category 'e-Business Business Logic'.  

Executing a database object

The Execute Data Object process flow is a generic way to execute a stored procedure through the business logic framework in services.  Rather than force users to create a process flow for every stored procedure they want to execute, we created a generic one that should meet the majority of needs.  It does require naming your input parameters according to our naming conventions.  But if you can do that, it should save you a chunk of work.

The process flow has the following input properties:

Input Property Type

Description

DataObjectName string The name of the database object to execute
Request object A POCO representing the client input
AuthenticatedAttributes object The current authenticated attributes object for the caller.

This process flow will look at the input parameters declared on the database object referenced by 'DataObjectName'.  If the parameter name is in the format @ObjectName_ParameterName the process component will assume 'objectName' is an object that exists in the input properties, and attempt to look up a value 'parameterName' on that object.  There are three types of objects the component understands for ObjectName:

  • If the object is a primitive type its value is used for the DBO parameter.  
  • If the object is an instance of IInputContext then the component will ask the context object for the value of ParameterName and use that for the DBO parameter
  • If the object is a POCO and a public instance property exists on the object with the same name as 'ParameterName', the property will be retrieved used for the DBO parameter

Examples

Let's assume we have the following endpoint defined

{
  "endpoints": {
    "ExamplesGetSingleProduct": {
      "route": {
        "httpMethod": "GET",
        "segments": {
          "examples": {
            "isLiteral": true,
            "type": "string"
          },
          "products": {
            "isLiteral": true,
            "type": "string"
          },
          "productId": {
            "isLiteral": false,
            "type": "long"
          }
        }
      },
      "businessLogic": {
        "allProductsRetrieval": {
          "executionType": "processFlow",
          "processFlowProperties": {
            "processFlowName": "Execute Data Object",
            "processFlowParameters": {
              "DataObjectName": "spGeteBusiness6_0ProductCatalog",
              "authenticatedAttributes": "@AuthenticatedAttributes"
            }
          }
        }
      }
	  //remaining metadata omitted
    }
  }
}

We want spGeteBusiness6_0ProductCatalog to return product information for the requested product id and with pricing information appropriate for the current user.  If we define our database object like this:

CREATE PROCEDURE spGeteBusiness6_0ProductCatalog
(      
  @Request_ProductId INT,
  @AuthenticatedAttributes_AuthenticatedPrincipalRecordId INT
)
--stored procedure body ommitted 

The system will automatically map those parameters for you.  @Request_ProductId will have the product ID from the URL, and @ AuthenticatedAttributes_AuthenticatedPrincipalRecordId will be the logged in person ID, or the anonymous person if the user is not authenticated.  


Retrieving, deleting or saving a GE

The GET GE Object process flow can be used to retrieve a GE based on some piece of client input.  

Input Parameter Type Description
entityName string The type of GE that should be retrieved
clientPocoFieldName string An optional parameter that tells the component which field on the client input to get for the ID value when making the GetEntityObject call. By default 'id' is used.


Mapping client data into a GE

You often want to map fields on the client input directly onto an instance of the GE.  The Map Input POCO to GE process flow accomplishes that.  It will also respect sourceField settings from the input entity definition, mapping public facing fields through to other fields on the GE.  

Input Property Type Description
requestPoco object The client input object. This can always be obtained from the input context lookup '@request.objectValue'.
geObjectToMap object A generic entity to assign values to.
inputFieldsToIgnore string A comma delimited list of fields on the requestPoco to skip mapping.


Save or Delete a GE

The process flow Execute GE Action will save or delete a GE.  It accepts the following input properties:

Input Property Type Description
action string A value of 'create' or 'save' will call Save on the GE. 'delete' will call Delete. 'get' will do nothing.
GE object The GE to perform the action on.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.