You are here

Custom Data Models

You can create Custom Data Models that connect to external sources and perform custom data operations when working with entity objects.

Implementing the Custom Data Model service

Implement AlfrescoCustomDataModelService to manage operations such as insert, update, and select data in Custom Data Models.

interface: com.activiti.api.datamodel.AlfrescoCustomDataModelService

maven module: activiti-app-logic

To implement the AlfrescoCustomDataModelService interface:

  1. Create an external class named AlfrescoCustomDataModelServiceImpl and add it to the classpath.

    Note that it should be in a package that can be scanned, such as com.activiti.extension.bean.

  2. Implement the class as follows:
    package com.activiti.extension.bean;
    import java.util.List;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Service;
    import com.activiti.api.datamodel.AlfrescoCustomDataModelService;
    import com.activiti.model.editor.datamodel.DataModelDefinitionRepresentation;
    import com.activiti.model.editor.datamodel.DataModelEntityRepresentation;
    import com.activiti.runtime.activiti.bean.datamodel.AttributeMappingWrapper;
    import com.activiti.variable.VariableEntityWrapper;
    import com.fasterxml.jackson.databind.ObjectMapper;
    import com.fasterxml.jackson.databind.node.ObjectNode;
    public class AlfrescoCustomDataModelServiceImpl implements AlfrescoCustomDataModelService {
        protected ObjectMapper objectMapper;
        public String storeEntity(List<AttributeMappingWrapper> attributeDefinitionsAndValues, DataModelEntityRepresentation entityDefinition,
                DataModelDefinitionRepresentation dataModel) {
            // save entity data and return entity id
        public ObjectNode getMappedValue(DataModelEntityRepresentation entityValue, String mappedName, Object variableValue) {
            // fetch entity data and return as an ObjectNode
        public VariableEntityWrapper getVariableEntity(String keyValue, String variableName, String processDefinitionId, DataModelEntityRepresentation entityValue) {
            // fetch entity data and return as a VariableEntityWrapper

This implementation of AlfrescoCustomDataModelServiceImpl class is called, for example, when a select, insert, or update operation on a custom data model is performed.

Sending feedback to the Alfresco documentation team

You don't appear to have JavaScript enabled in your browser. With JavaScript enabled, you can provide feedback to us using our simple form. Here are some instructions on how to enable JavaScript in your web browser.